<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
  <link rel="stylesheet" type="text/css" href="css/report.css" />
  <link rel="stylesheet" type="text/css" href="css/swiper.min.css" />
  <script type="text/javascript" src="./json/languages.js"></script>
  <title>Report</title>
</head>

<body>
  <div class="page">
    <div class="title-row-top" id="title-row" style="display: block"></div>
    <div class="time-toprow" id="time-toptext"></div>
    <div class="tab-row">
      <div class="tabs">
        <div class="day active" id="day">
          <div class="tab-text">1 day</div>
        </div>
        <div class="line_1" id="line_1"></div>
        <div class="week" id="week">
          <div class="tab-text">1 week</div>
        </div>
        <div class="line_2" id="line_2"></div>
        <div class="month" id="month">
          <div class="tab-text">1 month</div>
        </div>
        <div class="line_3" id="line_3"></div>
        <div class="year" id="year">
          <div class="tab-text">1 year</div>
        </div>
      </div>
    </div>
    <div class="swiper-container">
      <div class="swiper-wrapper">
        <div class="swiper-slide swiper-no-swiping">
          <!--日报-->
          <div class="card_1" id="card1_1" style="display: block">
            <div class="title-row" style="height: 28%">
              <img class="img title-img" src="image/sleep_stage.png" />
              <div class="title-text-week2" id="title-text-day">
                0 hr 0 min
              </div>
            </div>
            <div class="subtext-week" id="day_subtext"></div>
            <div class="card-line"></div>
            <div class="deep stage-row">
              <div class="deep-dot"></div>
              <div class="deep-text">Deep</div>
              <div class="deep-data" id="deep-data">0 hr 0 min</div>
            </div>
            <div class="light stage-row">
              <div class="light-dot" style="background: #26baab"></div>
              <div class="light-text">Light</div>
              <div class="light-data" id="light-data">0 hr 0 min</div>
            </div>
            <div class="awake stage-row">
              <div class="awake-dot" style="background: #cad7d6"></div>
              <div class="awake-text">Awake</div>
              <div class="awake-data" id="awake-data">0 hr 0 min</div>
            </div>
          </div>
          <div class="card2_1">
            <div class="title-row2">
              <img class="img title-img" src="image/sleep_stage.png" />
              <div class="title-text-day" id="title-text-day">0 hr 0 min</div>
            </div>
            <div class="card-line2"></div>
            <div class="deep-alone stage-row">
              <div class="deep-data2" id="deep-data0" style="width: 80%; text-align: left">
                0% of your evening rest
              </div>
            </div>
          </div>
          <div class="card3_1" style="height: 23.7vw">
            <img class="img title-img" style="top: 40%" src="image/sleep_stage.png" />
            <div class="title-text-week1" id="title-text-day">0 hr 0 min</div>
            <div class="subtext-week" style="top: 60%">24 hour average</div>
          </div>
          <div class="card4_1" style="display: none; min-height: 43.2vw">
            <div class="title-row4" style="margin-bottom: 4%">
              <img class="img title-img" src="image/sleep_stage.png" />
              <div class="title-text-day" id="title-text-day">0 hr 0 min</div>
            </div>
            <div class="card-line4"></div>
            <div class="text-tow" id="snore-row">
              <!-- <div class="row">
                  <div class="snore_time"></div>
                  <div class="time_length"></div>
                </div> -->
            </div>
          </div>
          <div class="card5_1" style="display: none; height: 43.2vw">
            <div class="title-row">
              <img class="img title-img" src="image/sleep_stage.png" />
              <div class="title-text-day" id="title-text-day">0 hr 0 min</div>
            </div>
            <div class="card-line"></div>
            <div class="deep stage-row">
              <div class="deep-dot" style="background-color: #f5af00"></div>
              <div class="deep-text">Large movements</div>
              <div class="deep-data" id="deep-data">0 times</div>
            </div>
            <div class="light stage-row" style="margin-top: 4%">
              <div class="light-dot" style="background: #cacece"></div>
              <div class="light-text">Small movements</div>
              <div class="light-data" id="light-data">0 times</div>
            </div>
          </div>
          <div class="card_2" id="card_2">
            <div class="time-row">
              <div class="left-time" id="left-time"></div>
              <div class="right-time" id="right-time"></div>
            </div>
            <div class="card_chart" id="chart_awake" style="margin-top: 10%; height: 25%"></div>
            <div class="card_chart" id="chart_light" style="height: 25%"></div>
            <div class="card_chart" id="chart_deep"></div>
            <!--睡眠分期日报-->
            <div class="daychart_sleepstage_x" id="daychart_sleepstage_x">
              <div class="xlabel_1" id="sleepstage_x_1"></div>
              <div class="xlabel_2" id="sleepstage_x_2"></div>
              <div class="xlabel_3" id="sleepstage_x_3"></div>
              <div class="xlabel_4" id="sleepstage_x_4"></div>
            </div>
            <!--其他报告日报-->
            <div class="daychart_sleepstage_x2" id="daychart_sleepstage_x2">
              <div class="xlabel_1" id="sleepstage_x_21"></div>
              <div class="xlabel_2" id="sleepstage_x_22"></div>
              <div class="xlabel_3" id="sleepstage_x_23"></div>
              <div class="xlabel_4" id="sleepstage_x_24"></div>
            </div>
          </div>
          <div class="snoretips_card" id="snoretips_card" style="display: block">
            <div class="top-row">
              <img class="snore_img" src="image/snore_img.png" />
              <div class="top-text" id="top-text1">0 Auto Adjustments</div>
            </div>
            <div class="card-line5"></div>
            <div class="tips-content">
              Your bed automatically adjusted to the Dawn House pre-programmed
              Anti Snore position. This helps open your lungs and airway,
              resulting in calmer, deeper breathing.
            </div>
          </div>
          <div class="card_3">
            <div class="detail-title">
              Reaching all of the stages of the sleep cycle is crucial to your
              health and well-being.
            </div>
            <div class="detail-content">
              The cycles include, Light Sleep, which happens no matter how
              much sleep you get, Deep Sleep, which in many ways is more
              restorative. Together the stages make up the sleep cycle which
              works to heal and restore the body.
            </div>
          </div>
          <div class="hrvcard size1">
            <div class="hrv_title">LF/HF Nervous System Function</div>
            <div class="hrv_line"></div>
            <div class="hrv_num_1">0</div>
            <div class="hrv_text">
              The ratio of low to high frequency components (LF/HF) represents
              the balance between sympathetic and parasympathetic nerves.
            </div>
          </div>
          <div class="hrvcard size2">
            <div class="hrv_title">pNN50 Heart Beat</div>
            <div class="hrv_line"></div>
            <div class="hrv_num_2">0</div>
            <div class="hrv_text">
              pNN50 represents the percentage of total heart beats where the
              difference between adjacent hearts is greater than 50ms.
            </div>
          </div>
          <div class="hrvcard size2">
            <div class="hrv_title">RMSSD Nervous System Function</div>
            <div class="hrv_line"></div>
            <div class="hrv_num_3">0</div>
            <div class="hrv_text">
              RMSSD represents the difference in length between all adjacent
              cardiac intervals to assess nervous system activity.
            </div>
          </div>
          <div class="hrvcard size1" style="margin-bottom: 4.3vw">
            <div class="hrv_title">SDNN Cardiac Nervous System</div>
            <div class="hrv_line"></div>
            <div class="hrv_num_4">0</div>
            <div class="hrv_text">
              SDNN represents the standard deviation of all cardiac intervals
              and reflects the overall regulatory capacity of the cardiac
              autonomic nervous system.
            </div>
          </div>
        </div>
        <div class="swiper-slide swiper-no-swiping">
          <!--周报-->
          <div class="card_week_1">
            <div class="title-row" style="height: 28%; margin-bottom: 2%">
              <img class="img title-img" src="image/sleep_stage.png" />
              <div class="title-text-week2">0 hr 0 min</div>
            </div>
            <div class="subtext-week">Nightly average</div>
            <div class="card-line-week"></div>
            <!-- <div class="lab">Total hours</div> -->
            <div class="deep-week stage-row adjust">
              <div class="deep-dot"></div>
              <div class="deep-text">Deep</div>
              <div class="deep-data_2">0 hr 0 min</div>
            </div>
            <div class="light stage-row adjust">
              <div class="light-dot" style="background: #26baab"></div>
              <div class="light-text">Light</div>
              <div class="light-data_2">0 hr 0 min</div>
            </div>
            <div class="awake stage-row adjust">
              <div class="awake-dot" style="background: #cad7d6"></div>
              <div class="awake-text">Awake</div>
              <div class="awake-data_2">0 hr 0 min</div>
            </div>
          </div>
          <div class="card2_2" style="display: none; height: 39.7vw">
            <div class="title-row2">
              <img class="img title-img" style="top: 40%" src="image/sleep_stage.png" />
              <div class="title-text-week2" id="title-text-day2" style="top: 40%">
                0 hr 0 min
              </div>
            </div>
            <div class="subtext-week" style="top: 34%">Nightly average</div>
            <!-- <div class="card-line2"></div>
            <div class="deep stage-row">
              <div class="deep-data" id="deep-data2">0 hr 0 min</div>
            </div> -->
          </div>
          <div class="card3_1" style="height: 23.7vw">
            <img class="img title-img" style="top: 40%" src="image/sleep_stage.png" />
            <div class="title-text-week2" id="title-text-day">0 hr 0 min</div>
            <div class="subtext-week" style="top: 60%">Nightly average</div>
          </div>
          <div class="card_2">
            <div class="chart-title" id="weeklab">
              Nightly Averages, 4/13 - 4/19
            </div>
            <div class="chart" id="chart_week_total"></div>
            <div class="chart" id="chart_week"></div>
            <!--睡眠分期总体报告-->
            <div class="chart_week_x" id="chart_week_x">
              <div class="week_xlabel_1" id="week_x_1"></div>
              <div class="week_xlabel_2" id="week_x_2"></div>
              <div class="week_xlabel_3" id="week_x_3"></div>
              <div class="week_xlabel_4" id="week_x_4"></div>
            </div>
          </div>
          <div class="snoretips_card" id="snoretips_card" style="display: block">
            <div class="top-row">
              <img class="snore_img" src="image/snore_img.png" />
              <div class="top-text" id="top-text2">2 auto adjustments</div>
            </div>
            <div class="card-line5"></div>
            <div class="tips-content">
              Your bed automatically adjusted to the Dawn House pre-programmed
              Anti Snore position. This helps open your lungs and airway,
              resulting in calmer, deeper breathing.
            </div>
          </div>
          <div class="card_3">
            <div class="detail-title">
              Reaching all of the stages of the sleep cycle is crucial to your
              health and well-being.
            </div>
            <div class="detail-content">
              The cycles include, Light Sleep, which happens no matter how
              much sleep you get, Deep Sleep, which in many ways is more
              restorative. Together the stages make up the sleep cycle which
              works to heal and restore the body.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">LF/HF Nervous System Function</div>
            <div class="hrv_week_num1">0</div>
            <div class="hrv_week_lab">Nightly average</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Nightly Averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="lfhf"></div>
            <div class="hrv_week_tips">
              The ratio of low to high frequency components (LF/HF) represents
              the balance between sympathetic and parasympathetic nerves.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">pNN50 Heart Beat</div>
            <div class="hrv_week_num2">0</div>
            <div class="hrv_week_lab">Nightly average</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Nightly Averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="pnn50"></div>
            <div class="hrv_week_tips">
              pNN50 represents the percentage of total heart beats where the
              difference between adjacent hearts is greater than 50ms.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">RMSSD Nervous System Function</div>
            <div class="hrv_week_num3">0</div>
            <div class="hrv_week_lab">Nightly average</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Nightly Averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="rmssd"></div>
            <div class="hrv_week_tips">
              RMSSD represents the difference in length between all adjacent
              cardiac intervals to assess nervous system activity.
            </div>
          </div>
          <div class="hrvcard size3" style="margin-bottom: 4.3vw">
            <div class="hrv_week_title">SDNN Cardiac Nervous System</div>
            <div class="hrv_week_num4">0</div>
            <div class="hrv_week_lab">Nightly average</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Nightly Averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="sdnn"></div>
            <div class="hrv_week_tips">
              SDNN represents the standard deviation of all cardiac intervals
              and reflects the overall regulatory capacity of the cardiac
              autonomic nervous system.
            </div>
          </div>
        </div>
        <div class="swiper-slide swiper-no-swiping">
          <!--月报-->
          <div class="card_week_1">
            <div class="title-row" style="height: 28%; margin-bottom: 2%">
              <img class="img title-img" src="image/sleep_stage.png" />
              <div class="title-text-week3">0 hr 0 min</div>
            </div>
            <div class="subtext-week">Weekly averages</div>
            <div class="card-line-week"></div>
            <!-- <div class="lab">Total hours</div> -->
            <div class="deep-week stage-row adjust">
              <div class="deep-dot"></div>
              <div class="deep-text">Deep</div>
              <div class="deep-data3">0 hr 0 min</div>
            </div>
            <div class="light stage-row adjust">
              <div class="light-dot" style="background: #26baab"></div>
              <div class="light-text">Light</div>
              <div class="light-data3">0 hr 0 min</div>
            </div>
            <div class="awake stage-row adjust">
              <div class="awake-dot" style="background: #cad7d6"></div>
              <div class="awake-text">Awake</div>
              <div class="awake-data3">0 hr 55 min</div>
            </div>
          </div>
          <div class="card2_2" style="display: none; height: 39.7vw">
            <div class="title-row2">
              <img class="img title-img" style="top: 40%" src="image/sleep_stage.png" />
              <div class="title-text-week2" id="title-text-day3" style="top: 40%">
                0 hr 0 min
              </div>
            </div>
            <div class="subtext-week" style="top: 34%">Weekly averages</div>
            <div class="card-line2"></div>
            <div class="deep stage-row">
              <div class="deep-data" id="deep-data3">0 hr 0 min</div>
            </div>
          </div>
          <div class="card3_1" style="height: 23.7vw">
            <img class="img title-img" style="top: 40%" src="image/sleep_stage.png" />
            <div class="title-text-week3" id="title-text-day">0 hr 0 min</div>
            <div class="subtext-week" style="top: 60%">Weekly averages</div>
          </div>
          <div class="card_2">
            <div class="chart-title" id="monthlab">
              Weekly averages, 4/13 - 4/19
            </div>
            <div class="chart" id="chart_month_total"></div>
            <div class="chart" id="chart_month"></div>
            <!--月报x轴-->
            <div class="chart_month_x" id="chart_month_x">
              <div class="month_xlabel_1" id="month_x_1"></div>
              <div class="month_xlabel_2" id="month_x_2"></div>
              <div class="month_xlabel_3" id="month_x_3"></div>
              <div class="month_xlabel_4" id="month_x_4"></div>
            </div>
          </div>
          <div class="snoretips_card" id="snoretips_card" style="display: block">
            <div class="top-row">
              <img class="snore_img" src="image/snore_img.png" />
              <div class="top-text" id="top-text3">2 auto adjustments</div>
            </div>
            <div class="card-line5"></div>
            <div class="tips-content">
              Your bed automatically adjusted to the Dawn House pre-programmed
              Anti Snore position. This helps open your lungs and airway,
              resulting in calmer, deeper breathing.
            </div>
          </div>
          <div class="card_3">
            <div class="detail-title">
              Reaching all of the stages of the sleep cycle is crucial to your
              health and well-being.
            </div>
            <div class="detail-content">
              The cycles include, Light Sleep, which happens no matter how
              much sleep you get, Deep Sleep, which in many ways is more
              restorative. Together the stages make up the sleep cycle which
              works to heal and restore the body.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">LF/HF Nervous System Function</div>
            <div class="hrv_month_num1">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Weekly averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="m_lfhf"></div>
            <div class="hrv_week_tips">
              The ratio of low to high frequency components (LF/HF) represents
              the balance between sympathetic and parasympathetic nerves.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">pNN50 Heart Beat</div>
            <div class="hrv_month_num2">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Weekly averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="m_pnn50"></div>
            <div class="hrv_week_tips">
              pNN50 represents the percentage of total heart beats where the
              difference between adjacent hearts is greater than 50ms.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">RMSSD Nervous System Function</div>
            <div class="hrv_month_num3">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Weekly averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="m_rmssd"></div>
            <div class="hrv_week_tips">
              RMSSD represents the difference in length between all adjacent
              cardiac intervals to assess nervous system activity.
            </div>
          </div>
          <div class="hrvcard size3" style="margin-bottom: 4.3vw">
            <div class="hrv_week_title">SDNN Cardiac Nervous System</div>
            <div class="hrv_month_num4">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Weekly averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="m_sdnn"></div>
            <div class="hrv_week_tips">
              SDNN represents the standard deviation of all cardiac intervals
              and reflects the overall regulatory capacity of the cardiac
              autonomic nervous system.
            </div>
          </div>
        </div>
        <div class="swiper-slide swiper-no-swiping">
          <!--年报-->
          <div class="card_week_1">
            <div class="title-row" style="height: 28%; margin-bottom: 2%">
              <img class="img title-img" src="image/sleep_stage.png" />
              <div class="title-text-week3">0 hr 0 min</div>
            </div>
            <div class="subtext-week">Weekly averages</div>
            <div class="card-line-week"></div>
            <!-- <div class="lab">Total hours</div> -->
            <div class="deep-week stage-row adjust">
              <div class="deep-dot"></div>
              <div class="deep-text">Deep</div>
              <div class="deep-data3">0 hr 0 min</div>
            </div>
            <div class="light stage-row adjust">
              <div class="light-dot" style="background: #26baab"></div>
              <div class="light-text">Light</div>
              <div class="light-data3">0 hr 0 min</div>
            </div>
            <div class="awake stage-row adjust">
              <div class="awake-dot" style="background: #cad7d6"></div>
              <div class="awake-text">Awake</div>
              <div class="awake-data3">0 hr 55 min</div>
            </div>
          </div>
          <div class="card2_2" style="display: none; height: 39.7vw">
            <div class="title-row2">
              <img class="img title-img" style="top: 40%" src="image/sleep_stage.png" />
              <div class="title-text-week2" id="title-text-day3" style="top: 40%">
                0 hr 0 min
              </div>
            </div>
            <div class="subtext-week" style="top: 34%">Weekly averages</div>
            <div class="card-line2"></div>
            <div class="deep stage-row">
              <div class="deep-data" id="deep-data3">0 hr 0 min</div>
            </div>
          </div>
          <div class="card3_1" style="height: 23.7vw">
            <img class="img title-img" style="top: 40%" src="image/sleep_stage.png" />
            <div class="title-text-week3" id="title-text-day">0 hr 0 min</div>
            <div class="subtext-week" style="top: 60%">Weekly averages</div>
          </div>
          <div class="card_2">
            <div class="chart-title" id="yearlab">
              Weekly averages, 4/13 - 4/19
            </div>
            <div class="chart" id="chart_year_total"></div>
            <div class="chart" id="chart_year"></div>
            <!--年报x轴-->
            <div class="chart_year_x" id="chart_year_x">
              <div class="year_xlabel_1" id="year_x_1"></div>
            </div>
            <div class="chart_year_x2" id="chart_year_x2">
              <div class="year_x2label_1" id="year_x2_1"></div>
              <div class="year_x2label_2" id="year_x2_2"></div>
            </div>
            <div class="chart_year_x3" id="chart_year_x3">
              <div class="year_x3label_1" id="year_x3_1"></div>
              <div class="year_x3label_2" id="year_x3_2"></div>
              <div class="year_x3label_3" id="year_x3_3"></div>
            </div>
            <div class="chart_year_x4" id="chart_year_x4">
              <div class="year_x4label_1" id="year_x4_1"></div>
              <div class="year_x4label_2" id="year_x4_2"></div>
              <div class="year_x4label_3" id="year_x4_3"></div>
              <div class="year_x4label_4" id="year_x4_4"></div>
            </div>
          </div>
          <div class="snoretips_card" id="snoretips_card" style="display: block">
            <div class="top-row">
              <img class="snore_img" src="image/snore_img.png" />
              <div class="top-text" id="top-text4">0 auto adjustments</div>
            </div>
            <div class="card-line5"></div>
            <div class="tips-content">
              Your bed automatically adjusted to the Dawn House pre-programmed
              Anti Snore position. This helps open your lungs and airway,
              resulting in calmer, deeper breathing.
            </div>
          </div>
          <div class="card_3">
            <div class="detail-title">
              Reaching all of the stages of the sleep cycle is crucial to your
              health and well-being.
            </div>
            <div class="detail-content">
              The cycles include, Light Sleep, which happens no matter how
              much sleep you get, Deep Sleep, which in many ways is more
              restorative. Together the stages make up the sleep cycle which
              works to heal and restore the body.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">LF/HF Nervous System Function</div>
            <div class="hrv_month_num1">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Weekly averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="y_lfhf"></div>
            <div class="hrv_week_tips">
              The ratio of low to high frequency components (LF/HF) represents
              the balance between sympathetic and parasympathetic nerves.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">pNN50 Heart Beat</div>
            <div class="hrv_month_num2">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Weekly averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="y_pnn50"></div>
            <div class="hrv_week_tips">
              pNN50 represents the percentage of total heart beats where the
              difference between adjacent hearts is greater than 50ms.
            </div>
          </div>
          <div class="hrvcard size3">
            <div class="hrv_week_title">RMSSD Nervous System Function</div>
            <div class="hrv_month_num3">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Nightly Averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="y_rmssd"></div>
            <div class="hrv_week_tips">
              RMSSD represents the difference in length between all adjacent
              cardiac intervals to assess nervous system activity.
            </div>
          </div>
          <div class="hrvcard size3" style="margin-bottom: 4.3vw">
            <div class="hrv_week_title">SDNN Cardiac Nervous System</div>
            <div class="hrv_month_num4">0</div>
            <div class="hrv_week_lab">Weekly averages</div>
            <div class="hrv-line-week"></div>
            <div class="hrv_week_daterow">Weekly averages, 4/13 - 4/19</div>
            <div class="hrv_week_chart" id="y_sdnn"></div>
            <div class="hrv_week_tips">
              SDNN represents the standard deviation of all cardiac intervals
              and reflects the overall regulatory capacity of the cardiac
              autonomic nervous system.
            </div>
          </div>
        </div>
        <div class="swiper-slide"></div>
      </div>
    </div>
  </div>
</body>
<script src="js/echart.js"></script>
<script src="js/jquery.js"></script>
<script src="js/swiper.js"></script>
<script src="js/common.js"></script>
<script src="js/drawreport.js"></script>
<script src="js/data.js"></script>
<script>
  /** 图表初始化 **/
  var chart_awake = echarts.init(document.getElementById("chart_awake")); //心率，醒来日报公用
  var chart_light = echarts.init(document.getElementById("chart_light"));
  var chart_deep = echarts.init(document.getElementById("chart_deep"));
  var chart_lfhf = echarts.init(document.getElementById("lfhf"));
  var chart_pnn50 = echarts.init(document.getElementById("pnn50"));
  var chart_rmssd = echarts.init(document.getElementById("rmssd"));
  var chart_sdnn = echarts.init(document.getElementById("sdnn"));
  var chart_lfhf2 = echarts.init(document.getElementById("m_lfhf"));
  var chart_pnn502 = echarts.init(document.getElementById("m_pnn50"));
  var chart_rmssd2 = echarts.init(document.getElementById("m_rmssd"));
  var chart_sdnn2 = echarts.init(document.getElementById("m_sdnn"));
  var stage = "day";
  var awake = [];
  var light = [];
  var deep = [];
  var time = [];
  var collect = [];
  var collect2 = []; //心率呼吸采样时间集
  var tmparr = [];
  var sonrelist = [];
  var languageData = {}; //语言类别
  var o;
  fontset();
  var account = getQueryVariable("account"); //用户账号
  //account = "347314525@qq.com";
  var user_id = getQueryVariable("user_id"); //用户id入参
  // var date = getQueryVariable("date") + " 00:00:00"; //日期入参
  var date = "2023-04-19 00:00:00"
  var token = getQueryVariable("token"); //token 入参
  var model = getQueryVariable("model"); //模块入参
  var host = getQueryVariable("host"); //动态路径
  var share = getQueryVariable("share"); //报告分享标志位
  var timetype = getQueryVariable("timetype"); //24h 12h标志位
  var languages = getQueryVariable("language"); //语言种类
  var viewtype = ""; //埋点入参name
  var report_type = ""; //埋点入参report_type
  var toptitle = "";
  var MonthArr = [
    "Jan",
    "Feb",
    "Mar",
    "Apr",
    "May",
    "June",
    "July",
    "Aug",
    "Sept",
    "Oct",
    "Nov",
    "Dec",
  ];
  var modelList = [
    "total",
    "deep",
    "light",
    "heart",
    "hrv",
    "breath",
    "snore",
    "move",
  ];
  var modelList2 = [
    "Total Sleep",
    "Deep Sleep",
    "Light Sleep",
    "Heart Rate",
    "Heart Rate Variability",
    "Respiratory Rate",
    "Snoring",
    "Movement",
  ];
  let temp = new Date(date.replace(/-/g, "/"));
  let temp2 = dateformat(new Date(), 0, 2);
  let yn = temp.getFullYear();
  let mn = temp.getMonth();
  let dn = temp.getDate();
  getLanguages(languages);
  $("#time-toptext").html(MonthArr[mn] + " " + dn + ", " + yn);

  var mySwiper;
  contentChange(model);
  drawchart(stage);
  initialization();

  /** Slide滑动初始化 **/
  setTimeout(() => {
    mySwiper = new Swiper(".swiper-container", {
      autoplay: false, //可选选项，自动滑动
      autoHeight: true,
      on: {
        slideChange: function () {
          // alert(this.activeIndex);//切换结束时，告诉我现在是第几个slide
          movecheck(this.activeIndex);
        },
      },
    });
  }, 300);
  //页面初始化
  function initialization() {
    report_type = 0;
    let winWidth = window.innerWidth;
    let height2_2 = "";
    let height_3 = "";
    if (share == 1) {
      //判断是否为别人分享的报告
      $("#title-row").css({ display: "block" });
      $("#time-toptext").css({ top: "47px" });
      $(".tab-row").css({ top: "68px" });
      $(".swiper-container").addClass("topstyle");
      let a = modelList.indexOf(model);
      toptitle = capitalize(modelList2[a]);
      $("#title-row").html(toptitle);
    } else {
      $("#title-row").css({ display: "none" });
      $("#title-row").html("");
    }
    if (model == "deep") {
      view_record("Deep_Sleep_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "block" });
      $("#daychart_sleepstage_x2").css({ display: "none" });
      $(".time-row").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".hrvcard").css({ display: "none" });
      $(".title-text-week2").css({ top: "40%" });
      $(".title-img").attr("src", "image/deep_sleep.png");
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "block" });
      $(".card_week_1").css({ display: "none" });
      $("#chart_awake").css({ display: "block", height: "25%" });
      $("#chart_light").css({ display: "block" });
      $("#chart_deep").css({ display: "block" });
      $(".card2_2").css({ display: "none" });
      $(".card3_1").css({ display: "none" });
      $("#deep-data").html("0% of your evening rest");
      $(".snoretips_card").css({ display: "none" });
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      // $('.card_3').css({ height: '324px' });
      if (winWidth >= 768) {
        $(".card_3").css({ height: "25.1vw" });
        $(".card2_2").css({ height: "17.9vw" });
        $(".detail-title").css("cssText", "line-height:22px");
        $(".detail-content").css("cssText", "line-height:22px");
      }
    } else if (model == "light") {
      view_record("Light_Sleep_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "block" });
      $("#daychart_sleepstage_x2").css({ display: "none" });
      $(".time-row").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".hrvcard").css({ display: "none" });
      $(".title-text-week2").css({ top: "40%" });
      $(".title-img").attr("src", "image/light_sleep.png");
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "block" });
      $("#chart_awake").css({ display: "block", height: "25%" });
      $("#chart_light").css({ display: "block" });
      $("#chart_deep").css({ display: "block" });
      $(".card2_2").css({ display: "none" });
      $(".card3_1").css({ display: "none" });
      $(".card_week_1").css({ display: "none" });
      $("#deep-data").html("0% of your evening rest");
      $(".snoretips_card").css({ display: "none" });
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      if (winWidth >= 768) {
        $(".card_3").css({ height: "22.1vw" });
        $(".card2_2").css({ height: "17.9vw" });
        $(".detail-title").css({ "margin-top": "4%" });
      } else {
        // $('.card_3').css({ height: '255px' });
      }
    } else if (model == "hrv") {
      view_record("HRV_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "none" });
      $("#daychart_sleepstage_x2").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".hrvcard").css({ display: "none" });
      $(".title-img").attr("src", "image/hrv.png");
      $(".card_week_1").css({ display: "none" });
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "none" });
      $(".card2_2").css({ display: "none" });
      $(".card_2").css({ display: "none" });
      $("#chart_awake").css({ display: "block", height: "90%" });
      $("#chart_light").css({ display: "none" });
      $("#chart_deep").css({ display: "none" });
      $(".snoretips_card").css({ display: "none" });
      // $('.text-adjust').css({ left: '4.7% !important' });
      $(".card3_1").css({ display: "block" });
      $(".deep-data").html("0 bpm avg");
      $(".deep-data2").html("0 bpm avg");
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      if (winWidth >= 768) {
        $(".card_3").css({ height: "24.1vw" });
        $(".card3_1").css({ height: "17.9vw" });
        $(".detail-title").css({ "margin-top": "4%" });
        $(".subtext-week").css("cssText", "top: 45% !important ");
      }
    } else if (model == "heart") {
      view_record("Heart_Rate_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "none" });
      $("#daychart_sleepstage_x2").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".hrvcard").css({ display: "none" });
      $(".title-img").attr("src", "image/heart_rate.png");
      $(".card_week_1").css({ display: "none" });
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "none" });
      $(".card2_2").css({ display: "none" });
      $(".card_2").css({ display: "block" });
      $("#chart_awake").css({ display: "block", height: "90%" });
      $("#chart_light").css({ display: "none" });
      $("#chart_deep").css({ display: "none" });
      $(".snoretips_card").css({ display: "none" });
      $(".time-row").css({ display: "none" });
      // $('.card_3').css({ height: '301px' });
      // $('.card_2_2').css({ display: 'none' });
      $(".card3_1").css({ display: "block" });
      $(".deep-data").html("0 bpm avg");
      $(".deep-data2").html("0 bpm avg");
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      if (winWidth >= 768) {
        $(".card_3").css({ height: "24.1vw" });
        $(".card3_1").css({ height: "17.9vw" });
        $(".detail-title").css({ "margin-top": "4%" });
        $(".subtext-week").css("cssText", "top: 45% !important ");
      }
    } else if (model == "breath") {
      view_record("Respiratory_Rate_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "none" });
      $("#daychart_sleepstage_x2").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".hrvcard").css({ display: "none" });
      $(".card_week_1").css({ display: "none" });
      $(".title-img").attr("src", "image/breath.png");
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "none" });
      $(".card2_2").css({ display: "none" });
      $(".card3_1").css({ display: "block" });
      $(".card_2").css({ display: "block" });
      $("#chart_awake").css({ display: "block", height: "90%" });
      $("#chart_light").css({ display: "none" });
      $("#chart_deep").css({ display: "none" });
      $(".snoretips_card").css({ display: "none" });
      $(".deep-data").html("0 average");
      $(".deep-data2").html("0 average");
      if (winWidth >= 768) {
        $(".card_3").css({ height: "22.1vw" });
        $(".card3_1").css({ height: "17.9vw" });
        $(".detail-title").css({ "margin-top": "4%" });
        $(".subtext-week").css("cssText", "top: 45% !important;");
      } else {
        // $('.card_3').css({ height: '232px' });
      }
    } else if (model == "snore") {
      view_record("Snoring_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "none" });
      $("#daychart_sleepstage_x2").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      $(".card_week_1").css({ display: "none" });
      $(".title-img").attr("src", "image/snoring.png");
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "none" });
      $(".card2_2").css({ display: "none" });
      $("#chart_awake").css({ display: "block", height: "90%" });
      $("#chart_light").css({ display: "none" });
      $("#chart_deep").css({ display: "none" });
      $(".card3_1").css({ display: "block" });
      $(".card4_1").css({ display: "none" });
      $(".card_2").css({ display: "none" });
      $(".hrvcard").css({ display: "none" });
      $(".card_3").css({ display: "block" });
      for (let i = 0; i < sonrelist.length; i++) {
        $("#snore-row").append(
          "<div class='row'><div class='snore_time'>" +
          sonrelist[i].time +
          "</div><div class='time_length'>" +
          sonrelist[i].length +
          "</div></div>"
        );
      }
      if (winWidth >= 768) {
        // $('.card_3').css({ height: '22.1vw' });
        $(".card_chart").css(
          "cssText",
          "margin-top: 6% !important;height:90%"
        );
        $(".snoretips_card").css(
          "cssText",
          "width: 65.9%;height: 23.3vw;border-radius: 24px;box-shadow: 0px 2px 6px 0px undefined; margin-top: 2%;"
        );
        $(".detail-title").css({ "margin-top": "4%" });
        $(".subtext-week").css("cssText", "top: 45% !important;");
        $(".card_3").css({ height: "24vw" });
      }
      $(".snoretips_card").css({ display: "block" });
    } else if (model == "move") {
      view_record("Movement_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "none" });
      $("#daychart_sleepstage_x2").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      $(".card_week_1").css({ display: "none" });
      if (model == "move") {
        $(".title-img").attr("src", "image/movement.png");
      } else {
        $(".title-img").attr("src", "image/outbed.png");
      }
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "none" });
      $(".card2_2").css({ display: "none" });
      $(".card3_1").css({ display: "block" });
      $(".card4_1").css({ display: "none" });
      $(".card_2").css({ display: "none" });
      $(".card5_1").css({ display: "none" });
      $(".card_3").css({ display: "block" });
      $(".hrvcard").css({ display: "none" });
      $(".snoretips_card").css({ display: "none" });
      if (winWidth >= 768) {
        // $('.card_3').css({ height: '22.1vw' });
        $(".card_chart").css(
          "cssText",
          "margin-top: 6% !important;height:90%"
        );
        // $('.snoretips_card').css(
        //   'cssText',
        //   'width: 65.9%;height: 23.3vw;border-radius: 24px;box-shadow: 0px 2px 6px 0px undefined; margin-top: 2%;'
        // );
        $(".detail-title").css({ "margin-top": "4%" });
        $(".subtext-week").css("cssText", "top: 45% !important;");
        $(".card_3").css({ height: "26vw" });
      }
    } else if (model == "outbed") {
      //view_record("Movement_Pageview", 1);
      $("#daychart_sleepstage_x").css({ display: "none" });
      $("#daychart_sleepstage_x2").css({ display: "block" });
      $("#chart_week_total").css({ display: "none" });
      $("#chart_week").css({ display: "block" });
      $("#chart_month_total").css({ display: "none" });
      $("#chart_month").css({ display: "block" });
      $("#chart_year_total").css({ display: "none" });
      $("#chart_year").css({ display: "block" });
      $(".title-text-week3").css("cssText", "top: 40% !important ");
      $(".card_week_1").css({ display: "none" });
      if (model == "move") {
        $(".title-img").attr("src", "image/movement.png");
      } else {
        $(".title-img").attr("src", "image/outbed.png");
      }
      $(".card_1").css({ display: "none" });
      $(".card2_1").css({ display: "none" });
      $(".card2_2").css({ display: "none" });
      $(".card3_1").css({ display: "block" });
      $(".card4_1").css({ display: "none" });
      $(".card_2").css({ display: "none" });
      $(".card5_1").css({ display: "none" });
      $(".card_3").css({ display: "block" });
      $(".hrvcard").css({ display: "none" });
      $(".snoretips_card").css({ display: "none" });
      if (winWidth >= 768) {
        // $('.card_3').css({ height: '22.1vw' });
        $(".card_chart").css(
          "cssText",
          "margin-top: 6% !important;height:90%"
        );
        // $('.snoretips_card').css(
        //   'cssText',
        //   'width: 65.9%;height: 23.3vw;border-radius: 24px;box-shadow: 0px 2px 6px 0px undefined; margin-top: 2%;'
        // );
        $(".detail-title").css({ "margin-top": "4%" });
        $(".subtext-week").css("cssText", "top: 45% !important;");
        $(".card_3").css({ height: "26vw" });
      }
    } else {
      view_record("Total_Sleep_Pageview", 1, 0);
      $("#daychart_sleepstage_x").css({ display: "block" });
      $("#daychart_sleepstage_x2").css({ display: "none" });
      $(".time-row").css({ display: "block" });
      $(".title-img").attr("src", "image/sleep_stage.png");
      $("#chart_week_total").css({ display: "block" });
      $("#chart_week").css({ display: "none" });
      $("#chart_month_total").css({ display: "block" });
      $("#chart_month").css({ display: "none" });
      $("#chart_year_total").css({ display: "block" });
      $("#chart_year").css({ display: "none" });
      $(".card_1").css({ display: "block" });
      $(".card2_1").css({ display: "none" });
      $(".card2_2").css({ display: "none" });
      $(".card3_1").css({ display: "none" });
      $(".deep-data").removeClass("text-adjust");
      $(".title-text-week2").css({ top: "50%" });
      $(".hrvcard").css({ display: "none" });
      $(".snoretips_card").css({ display: "none" });
      $(".card_week_1").css({ display: "block" });
      $(".title-text-week3").css("cssText", "top: 50% !important ");
      // $('.card_3').css({ height: '278px' });
      if (winWidth >= 768) {
        $(".subtext-week").css("cssText", "top: 18% !important;");
        $(".card_3").css("cssText", "height:23.3vw");
        $(".detail-title").css("cssText", "line-height:22px");
        $(".detail-content").css("cssText", "line-height:22px");
      }
    }
  }
  /** Tabs选项卡点击方法 **/
  $("#day").click(function () {
    if (report_type != 0) {
      view_record(viewtype, 2, report_type);
      report_type = 0;
      view_record(viewtype, 1, 0);
    }
    $("#day").addClass("active");
    $("#line_1").css({ display: "none" });
    $("#line_2").css({ display: "block" });
    $("#line_3").css({ display: "block" });
    $("#week").removeClass("active");
    $("#month").removeClass("active");
    $("#year").removeClass("active");
    mySwiper.slideTo(0, 500, false);
    if (model == "move") {
      $(".card_2").css({ display: "none" });
    }
    stage = "day";
    drawchart(stage);
  });
  $("#week").click(function () {
    if (report_type != 1) {
      view_record(viewtype, 2, report_type);
      report_type = 1;
      view_record(viewtype, 1, 1);
    }

    $("#week").addClass("active");
    $("#line_1").css({ display: "none" });
    $("#line_2").css({ display: "none" });
    $("#line_3").css({ display: "block" });
    $("#day").removeClass("active");
    $("#month").removeClass("active");
    $("#year").removeClass("active");
    mySwiper.slideTo(1, 500, false);
    stage = "week";
    drawchart(stage);
  });
  $("#month").click(function () {
    if (report_type != 2) {
      view_record(viewtype, 2, report_type);
      report_type = 2;
      view_record(viewtype, 1, 2);
    }
    $("#month").addClass("active");
    $("#line_1").css({ display: "block" });
    $("#line_2").css({ display: "none" });
    $("#line_2").css({ display: "none" });
    $("#day").removeClass("active");
    $("#week").removeClass("active");
    $("#year").removeClass("active");
    mySwiper.slideTo(2, 500, false);
    stage = "month";
    drawchart(stage);
  });
  $("#year").click(function () {
    if (report_type != 3) {
      view_record(viewtype, 2, report_type);
      report_type = 3;
      view_record(viewtype, 1, 3);
    }
    $("#year").addClass("active");
    $("#line_1").css({ display: "block" });
    $("#line_2").css({ display: "block" });
    $("#line_3").css({ display: "none" });
    $("#day").removeClass("active");
    $("#week").removeClass("active");
    $("#month").removeClass("active");
    mySwiper.slideTo(3, 500, false);
    stage = "year";
    drawchart(stage);
  });
  //左右滑动判断
  $(".swiper-container").on("touchstart", function (e) {
    // e.preventDefault();
    startX = e.originalEvent.changedTouches[0].pageX;
    startY = e.originalEvent.changedTouches[0].pageY;
  });
  $(".swiper-container").on("touchend", function (e) {
    // e.preventDefault();
    moveEndX = e.originalEvent.changedTouches[0].pageX;
    (moveEndY = e.originalEvent.changedTouches[0].pageY),
      (X = moveEndX - startX);
    Y = moveEndY - startY;
    if (Math.abs(X) > 100 && X > 0) {
      //从左往右滑
      let a = modelList.indexOf(model);
      if (a > 0) {
        model = modelList[a - 1];
        toptitle = capitalize(modelList2[a - 1]);
        $("title").html(toptitle);
        view_record(viewtype, 2, report_type);
        initialization();
        console.log("model0", model);
        $("#day").addClass("active");
        $("#line_1").css({ display: "none" });
        $("#line_2").css({ display: "block" });
        $("#week").removeClass("active");
        $("#month").removeClass("active");
        $("#year").removeClass("active");
        mySwiper.slideTo(0, 500, false);
        stage = "day";
        drawchart(stage);
      } else {
      }
      // console.log("left 2 right");
    }
    if (Math.abs(X) > 100 && X < 0) {
      let a = modelList.indexOf(model);
      if (a >= 7) {
      } else {
        model = modelList[a + 1];
        toptitle = capitalize(modelList2[a + 1]);
        $("title").html(toptitle);
        view_record(viewtype, 2, report_type);
        initialization();
        $("#day").addClass("active");
        $("#line_1").css({ display: "none" });
        $("#line_2").css({ display: "block" });
        $("#week").removeClass("active");
        $("#month").removeClass("active");
        $("#year").removeClass("active");
        mySwiper.slideTo(0, 500, false);
        stage = "day";
        drawchart(stage);
      }
      // console.log("right 2 left");
    }
  });
  //获取语言类别并初始化
  function getLanguages(language) {
    if (language == "en") {
      languageData = jsonData.en.data;
    } else {
      languageData = jsonData.fr.data;
    }
    initLangugae();
  }
  //根据语言初始化部分固定内容
  function initLangugae() {
    $(".deep-text").html(languageData.lab_1);
    $(".light-text").html(languageData.lab_2);
    $(".awake-text").html(languageData.lab_3);
    $(".snoretips_card .tips-content").html(languageData.snore_text2);
    $(".day .tab-text").html("1 " + languageData.tab_1);
    $(".week .tab-text").html("1 " + languageData.tab_2);
    $(".month .tab-text").html("1 " + languageData.tab_3);
    $(".year .tab-text").html("1 " + languageData.tab_4);

    //月份切换
    MonthArr = languageData.month;
    //分享标题切换
    modelList2 = languageData.modelList;
  }
  /** 图表绘制 **/
  function drawchart(stage) {
    if (stage == "day") {
      getdayreport();
      // timeformat(date, stage);
    }
    if (stage == "week") {
      getweekreport();
      // timeformat(date, stage);
    }
    if (stage == "month") {
      getmonthreport();
    }
    if (stage == "year") {
      getyearreport();
    }
  }
  //数据埋点方法 0-点击，1-浏览开始，2-浏览结束 | 0-日，1-周，2-月，3-年
  async function view_record(name, type, report_type) {
    viewtype = name;
    report_type = report_type;
    if (host == 1) {
      url =
        "https://wellness.ergomotion.com/agingInPlace/api/v1/operate/operateLog";
    } else {
      url =
        "https://resthomeus.smartbed.top/agingInPlace/api/v1/operate/operateLog";
    }
    $.ajax({
      url: url,
      type: "POST",
      data: JSON.stringify({
        account_number: account,
        click_name: name,
        click_type: type,
        report_type: report_type,
        place: "WEB",
        click_time: Math.trunc(new Date().getTime() / 1000),
      }),
      headers: { Authorization: token },
      contentType: "application/json",
      success: function (res) {
        if (res.code == 10000) {
          console.log(name + ":" + type + " success");
        } else {
          console.log("error===>", res.message);
        }
      },
    });
  }

  //日报
  function getdayreport() {
    var tmparr = [];
    let url = "";
    if (host == 1) {
      url =
        "https://wellness.ergomotion.com/agingInPlace/api/v1/sleep/getSleepDay";
    } else {
      url =
        "https://resthomeus.smartbed.top/agingInPlace/api/v1/sleep/getSleepDay";
    }
    $("#time-toptext").html(MonthArr[mn] + " " + dn + ", " + yn);
    mockDayData()
    // $.ajax({
    //   url: url,
    //   type: "GET",
    //   data: {
    //     user_id: user_id,
    //     date: date.substring(0, 10),
    //   },
    //   headers: { Authorization: token },
    //   datatype: "application/json",
    //   success: function (res) {
    //     if (res.code == 10000) {
    //       showduration(
    //         res.data.sleep_duration,
    //         res.data.deep_sleep_duration,
    //         res.data.shallow_sleep_duration,
    //         res.data.clear_duration + res.data.left_bed_duration
    //       );
    //       getcollect(res.data);
    //       sleep_x_handler(res.data.sleep_stage);
    //       if (model == "heart" || model == "breath" || model == "hrv") {
    //         $(".subtext-week").html(languageData.lab_8);
    //       } else {
    //         if (res.data.sleep_time) {
    //           if (timetype == 12) {
    //             $(".subtext-week").html(
    //               dateformat(res.data.sleep_time.replace(/-/g, "/"), 0, 3) +
    //               " - " +
    //               dateformat(res.data.wake_time.replace(/-/g, "/"), 0, 3)
    //             );
    //           } else {
    //             $(".subtext-week").html(
    //               dateformat(res.data.sleep_time.replace(/-/g, "/"), 0, 4) +
    //               " - " +
    //               dateformat(res.data.wake_time.replace(/-/g, "/"), 0, 4)
    //             );
    //           }
    //         }
    //       }
    //       if (timetype == 12) {
    //         if (res.data.sleep_time) {
    //           $("#left-time").html(
    //             dateformat(res.data.sleep_time.replace(/-/g, "/"), 0, 3)
    //           );
    //         }
    //         if (res.data.wake_time) {
    //           $("#right-time").html(
    //             dateformat(res.data.wake_time.replace(/-/g, "/"), 0, 3)
    //           );
    //         }
    //       } else {
    //         if (res.data.sleep_time) {
    //           $("#left-time").html(
    //             dateformat(res.data.sleep_time.replace(/-/g, "/"), 0, 4)
    //           );
    //         }
    //         console.log("waketime", res.data.wake_time);
    //         if (res.data.wake_time) {
    //           $("#right-time").html(
    //             dateformat(res.data.wake_time.replace(/-/g, "/"), 0, 4)
    //           );
    //         }
    //       }
    //       if (model == "total") {
    //         console.log("time", $("#left-time").val());
    //         let leftvalue = document.getElementById("left-time").innerHTML;
    //         let rightvalue = document.getElementById("right-time").innerHTML;
    //         if (leftvalue != "" && rightvalue != "") {
    //           let label_x_1 = handletime(leftvalue, 1, timetype);
    //           let label_x_4 = handletime(rightvalue, 2, timetype);
    //           let label_x_2 = handletime2(label_x_1, label_x_4, timetype)[0];
    //           let label_x_3 = handletime2(label_x_1, label_x_4, timetype)[1];
    //           $("#sleepstage_x_1").html(label_x_1);
    //           $("#sleepstage_x_4").html(label_x_4);
    //           $("#sleepstage_x_2").html(label_x_2);
    //           $("#sleepstage_x_3").html(label_x_3);
    //         }
    //         drawdaychart1(chart_awake, awake, 3);
    //         drawdaychart2(chart_light, light, 2);
    //         drawdaychart3(chart_deep, deep, 1);
    //         //console.log('languageData.data===>', languageData)
    //         $(".detail-title").html(languageData.total_text);
    //         $(".detail-content").html(languageData.total_text2);
    //       } else if (model == "deep") {
    //         awake = [];
    //         light = [];
    //         let a =
    //           Math.round(
    //             (res.data.deep_sleep_duration * 100) / res.data.sleep_duration
    //           ) + languageData.lab_9;
    //         if (res.data.deep_sleep_duration > 60) {
    //           let b = Math.floor(res.data.deep_sleep_duration / 60);
    //           let c = res.data.deep_sleep_duration % 60;
    //           $(".title-text-day").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = res.data.deep_sleep_duration % 60;
    //           $(".title-text-day").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         $("#deep-data0").html(a);
    //         let leftvalue = document.getElementById("left-time").innerHTML;
    //         let rightvalue = document.getElementById("right-time").innerHTML;
    //         if (leftvalue != "" && rightvalue != "") {
    //           let label_x_1 = handletime(leftvalue, 1, timetype);
    //           let label_x_4 = handletime(rightvalue, 2, timetype);
    //           let label_x_2 = handletime2(label_x_1, label_x_4, timetype)[0];
    //           let label_x_3 = handletime2(label_x_1, label_x_4, timetype)[1];
    //           $("#sleepstage_x_1").html(label_x_1);
    //           $("#sleepstage_x_4").html(label_x_4);
    //           $("#sleepstage_x_2").html(label_x_2);
    //           $("#sleepstage_x_3").html(label_x_3);
    //         }
    //         drawdaychart1(chart_awake, awake, 3);
    //         drawdaychart2(chart_light, light, 2);
    //         drawdaychart3(chart_deep, deep, 1);
    //         $(".detail-title").html(languageData.deep_text);
    //         $(".detail-content").html(languageData.deep_text2);
    //       } else if (model == "light") {
    //         awake = [];
    //         deep = o;
    //         let a =
    //           Math.round(
    //             (res.data.shallow_sleep_duration * 100) /
    //             res.data.sleep_duration
    //           ) + languageData.lab_9;
    //         if (res.data.shallow_sleep_duration > 60) {
    //           let b = Math.floor(res.data.shallow_sleep_duration / 60);
    //           let c = res.data.shallow_sleep_duration % 60;
    //           $(".title-text-day").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = res.data.shallow_sleep_duration % 60;
    //           $(".title-text-day").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         $("#deep-data0").html(a);
    //         console.log("deep", deep);
    //         let leftvalue = document.getElementById("left-time").innerHTML;
    //         let rightvalue = document.getElementById("right-time").innerHTML;
    //         if (leftvalue != "" && rightvalue != "") {
    //           let label_x_1 = handletime(leftvalue, 1, timetype);
    //           let label_x_4 = handletime(rightvalue, 2, timetype);
    //           let label_x_2 = handletime2(label_x_1, label_x_4, timetype)[0];
    //           let label_x_3 = handletime2(label_x_1, label_x_4, timetype)[1];
    //           $("#sleepstage_x_1").html(label_x_1);
    //           $("#sleepstage_x_4").html(label_x_4);
    //           $("#sleepstage_x_2").html(label_x_2);
    //           $("#sleepstage_x_3").html(label_x_3);
    //         }
    //         drawdaychart1(chart_awake, awake, 3);
    //         drawdaychart2(chart_light, light, 2);
    //         drawdaychart3(chart_deep, deep, 1);
    //         $(".detail-title").html(languageData.light_text);
    //         $(".detail-content").html(languageData.light_text2);
    //       } else if (model == "heart") {
    //         let heart = JSON.parse(res.data.heart_rate_stage);
    //         let max = Math.max(...heart);
    //         let min = Math.min(...heart);
    //         let interval = Math.round(collect.length / 5);
    //         heart.unshift(heart[0]);
    //         $(".title-text-week1").html(res.data.avg_heart_rate + " bpm");
    //         $(".detail-title").html(languageData.heart_text);
    //         $(".detail-content").html(languageData.heart_text2);

    //         let leftvalue = "";
    //         let rightvalue = "";
    //         if (timetype == 12) {
    //           if (res.data.sleep_time) {
    //             leftvalue = dateformat(
    //               res.data.sleep_time.replace(/-/g, "/"),
    //               0,
    //               3
    //             );
    //           }
    //           if (res.data.wake_time) {
    //             rightvalue = dateformat(
    //               res.data.wake_time.replace(/-/g, "/"),
    //               0,
    //               3
    //             );
    //           }
    //         } else {
    //           if (res.data.sleep_time) {
    //             leftvalue = dateformat(
    //               res.data.sleep_time.replace(/-/g, "/"),
    //               0,
    //               4
    //             );
    //           }
    //           if (res.data.wake_time) {
    //             rightvalue = dateformat(
    //               res.data.wake_time.replace(/-/g, "/"),
    //               0,
    //               4
    //             );
    //           }
    //         }
    //         let label_x_1 = handletime(leftvalue, 1, timetype);
    //         let label_x_4 = handletime(rightvalue, 2, timetype);
    //         let label_x_2 = handletime2(label_x_1, label_x_4, timetype)[0];
    //         let label_x_3 = handletime2(label_x_1, label_x_4, timetype)[1];
    //         $("#sleepstage_x_21").html(label_x_1);
    //         $("#sleepstage_x_24").html(label_x_4);
    //         $("#sleepstage_x_22").html(label_x_2);
    //         $("#sleepstage_x_23").html(label_x_3);
    //         drawheartchart(chart_awake, heart, collect2, max, min, interval);
    //       } else if (model == "breath") {
    //         let breath = JSON.parse(res.data.breath_rate_stage);
    //         let max = Math.max(...breath);
    //         breath.unshift(breath[0]);
    //         $(".title-text-week1").html(
    //           res.data.avg_breath_rate + " " + languageData.lab_14
    //         );
    //         $(".detail-title").html(languageData.breath_text);
    //         $(".detail-content").html(languageData.breath_text2);
    //         let leftvalue = "";
    //         let rightvalue = "";
    //         if (timetype == 12) {
    //           leftvalue = dateformat(
    //             res.data.sleep_time.replace(/-/g, "/"),
    //             0,
    //             3
    //           );
    //           rightvalue = dateformat(
    //             res.data.wake_time.replace(/-/g, "/"),
    //             0,
    //             3
    //           );
    //         } else {
    //           leftvalue = dateformat(
    //             res.data.sleep_time.replace(/-/g, "/"),
    //             0,
    //             4
    //           );
    //           rightvalue = dateformat(
    //             res.data.wake_time.replace(/-/g, "/"),
    //             0,
    //             4
    //           );
    //         }
    //         let label_x_1 = handletime(leftvalue, 1, timetype);
    //         let label_x_4 = handletime(rightvalue, 2, timetype);
    //         let label_x_2 = handletime2(label_x_1, label_x_4, timetype)[0];
    //         let label_x_3 = handletime2(label_x_1, label_x_4, timetype)[1];
    //         $("#sleepstage_x_21").html(label_x_1);
    //         $("#sleepstage_x_24").html(label_x_4);
    //         $("#sleepstage_x_22").html(label_x_2);
    //         $("#sleepstage_x_23").html(label_x_3);
    //         drawbreathchart(chart_awake, breath, collect2, max);
    //       } else if (model == "move") {
    //         $(".title-text-week1").html(
    //           res.data.twitch_times +
    //           (res.data.twitch_times == 1
    //             ? " " + languageData.lab_10.slice(0, -1)
    //             : " " + languageData.lab_10)
    //         );
    //         $(".detail-title").html(languageData.move_text);
    //         $(".detail-content").html(languageData.move_text2);
    //       } else if (model == "hrv") {
    //         $(".title-text-week1").html(res.data.rmssd + " ms");
    //         $(".detail-title").html(languageData.hrv_text);
    //         $(".detail-content").html(languageData.hrv_text2);
    //       } else if (model == "snore") {
    //         let color = "rgba(38,186,171,1)";
    //         $(".title-text-week1").html(
    //           res.data.snore_times +
    //           (res.data.snore_times == 1
    //             ? " " + languageData.lab_11
    //             : " " + languageData.lab_12)
    //         );
    //         $("#top-text1").html(
    //           res.data.anti_snore_times +
    //           (res.data.anti_snore_times == 1
    //             ? " " + languageData.snore_text1
    //             : " " + languageData.snore_text)
    //         );
    //         $(".detail-title").html(languageData.snore_text3);
    //         $(".detail-content").html(languageData.snore_text4);
    //         let snore = [];
    //         snore = snorehandle(
    //           res.data.sleep_time,
    //           res.data.wake_time,
    //           res.data.anti_snore_stage,
    //           snore
    //         );
    //         drawsnorechart(chart_awake, snore, color);
    //       } else if (model == "outbed") {
    //         let temp = res.data.left_bed_time;
    //         if (temp != 1) {
    //           $(".title-text-week1").html(
    //             res.data.left_bed_time + (" " + languageData.lab_12)
    //           );
    //         } else {
    //           $(".title-text-week1").html(
    //             res.data.left_bed_time + (" " + languageData.lab_11)
    //           );
    //         }
    //         $(".detail-title").html(
    //           "Track the number of times you get out of bed at night to monitor changes in your health. "
    //         );
    //         $(".detail-content").html(
    //           "Increased frequency may be caused by: restless leg syndrome, sleep apnea, increased urination, medication, sleep disorders, pain, or other issues.  Getting out of bed at night can lead to increased fall risks. If you notice a change in this health metric you may want to contact your physician."
    //         );
    //       }
    //     }
    //   },
    //   failed: function (res) {
    //     console.log(res);
    //   },
    // });
  }
  //周报
  function getweekreport() {
    // let arr = [];
    // let arr2 = [];
    // let arr3 = [];
    // let arr4 = [];
    let startdate = dateformat(
      new Date(date.replace(/-/g, "/")).getTime() - 6 * 24 * 60 * 60 * 1000,
      0,
      2
    ).substring(0, 10);
    let url = "";
    if (host == 1) {
      url =
        "https://wellness.ergomotion.com/agingInPlace/api/v1/sleep/getSleepWeek";
    } else {
      url =
        "https://resthomeus.smartbed.top/agingInPlace/api/v1/sleep/getSleepWeek";
    }
    let temp1 = new Date(startdate.replace(/-/g, "/") + " 00:00:00");
    let yn1 = temp1.getFullYear();
    let mn1 = temp1.getMonth();
    let dn1 = temp1.getDate();
    if (yn1 != yn) {
      $("#time-toptext").html(
        MonthArr[mn1] +
        " " +
        dn1 +
        ", " +
        yn1 +
        " - " +
        MonthArr[mn] +
        " " +
        dn +
        ", " +
        yn
      );
    } else {
      $("#time-toptext").html(
        MonthArr[mn1] +
        " " +
        dn1 +
        " - " +
        MonthArr[mn] +
        " " +
        dn +
        ", " +
        yn
      );
    }
    mockWeekData()
    // $.ajax({
    //   url: url,
    //   type: "get",
    //   data: {
    //     user_id: user_id,
    //     start_date: startdate,
    //     end_date: date.substring(0, 10),
    //   },
    //   headers: {
    //     Authorization: token,
    //   },
    //   datatype: "application/json",
    //   success: function (res) {
    //     let sum = res.data;
    //     let avg = 0;
    //     let avg1 = 0;
    //     let avg2 = 0;
    //     let avg3 = 0;
    //     let days = 0;
    //     if (res.code == 10000) {
    //       let a = res.data.date;
    //       for (let i = 0; i < a.length; i++) {
    //         let temp_date = a[i].substring(5, 10).split("-");
    //         let temp_date_1 = parseInt(temp_date[0]).toString();
    //         let temp_date_2 = parseInt(temp_date[1]).toString();
    //         arr.push(temp_date_1 + "/" + temp_date_2);
    //         arr2.push(res.data.deep_sleep_durations[i]);
    //         arr3.push(res.data.shallow_sleep_durations[i]);
    //         arr4.push(res.data.clear_durations[i]);
    //         if (
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0) +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0) +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0) !=
    //           0
    //         ) {
    //           days = days + 1;
    //         }
    //         avg =
    //           avg +
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0) +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0) +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0);
    //         avg1 =
    //           avg1 +
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0);
    //         avg2 =
    //           avg2 +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0);
    //         avg3 =
    //           avg3 +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0);
    //       }
    //       let max;
    //       let max1 = Math.max(...arr2);
    //       let max2 = Math.max(...arr3);
    //       let max3 = Math.max(...arr4);
    //       if (max1 > max2) {
    //         if (max1 > max3) {
    //           max = max1;
    //         } else {
    //           max = max3;
    //         }
    //       } else {
    //         if (max2 > max3) {
    //           max = max2;
    //         } else {
    //           max = max3;
    //         }
    //       }
    //       $("#weeklab").html(
    //         languageData.lab_4 + ", " + arr[0] + "-" + arr[arr.length - 1]
    //       );
    //       $("#week_x_1").html(arr[0]);
    //       $("#week_x_2").html(arr[2]);
    //       $("#week_x_3").html(arr[4]);
    //       $("#week_x_4").html(arr[6]);
    //       if (model == "total") {
    //         var chart_week_total = echarts.init(
    //           document.getElementById("chart_week_total")
    //         );
    //         let s_0 = Math.round(avg / days); //大标题平均
    //         let a1 = Math.round(avg1 / days); //深睡平均
    //         let a2 = Math.round(avg2 / days); //浅睡平均
    //         let a3 = Math.round(avg3 / days); //清醒平均
    //         let mytemp1 = reRender(arr2);
    //         let mytemp2 = reRender(arr3);
    //         let mytemp3 = reRender(arr4);
    //         let arr2_0 = mytemp1.hasdata;
    //         let arr2_1 = mytemp1.nodata;
    //         let arr3_0 = mytemp2.hasdata;
    //         let arr3_1 = mytemp2.nodata;
    //         let arr4_0 = mytemp3.hasdata;
    //         let arr4_1 = mytemp3.nodata;
    //         drawweekchart(
    //           chart_week_total,
    //           arr2_0,
    //           arr2_1,
    //           arr3_0,
    //           arr3_1,
    //           arr4_0,
    //           arr4_1,
    //           arr,
    //           max
    //         );

    //         if (a1 + a2 > 60) {
    //           let b = Math.floor((a1 + a2) / 60);
    //           let c = (a1 + a2) % 60;
    //           $(".title-text-week2").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = s_0 % 60;
    //           $(".title-text-week2").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a1 > 60) {
    //           let b = Math.floor(a1 / 60);
    //           let c = a1 % 60;
    //           $(".deep-data_2").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a1.deep_sleep_duration % 60;
    //           $(".deep-data_2").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a2 > 60) {
    //           let b = Math.floor(a2 / 60);
    //           let c = a2 % 60;
    //           $(".light-data_2").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a2 % 60;
    //           $(".light-data_2").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a3 > 60) {
    //           let b = Math.floor(a3 / 60);
    //           let c = a3 % 60;

    //           $(".awake-data_2").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a3 % 60;
    //           $(".awake-data_2").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //       } else if (model == "deep") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let a1 = Math.round(avg1 / days); //深睡平均
    //         let color = "rgba(38, 84, 166, 1)";
    //         let color2 = "rgba(38, 84, 166, 1)";
    //         let color3 = "rgba(38, 84, 166, 0.2)";
    //         let color4 = "rgba(38, 84, 166, 0.93)";
    //         let mytemp = reRender(arr2);
    //         let arr2_0 = mytemp.hasdata;
    //         let arr2_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           arr2_0,
    //           arr2_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         console.log("a1", a1);
    //         if (a1 > 60) {
    //           let b = Math.floor(a1 / 60);
    //           let c = a1 % 60;
    //           // $('#deep-data2').html(b + ' hr ' + c + ' min');
    //           $(".title-text-week2").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a1 % 60;
    //           // $('#deep-data2').html(0 + ' hr ' + c + ' min');
    //           $(".title-text-week2").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         // if(sum.)
    //       } else if (model == "light") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let color = "rgba(38, 186, 171, 1)";
    //         let color2 = "rgba(38, 186, 171, 1)";
    //         let color3 = "rgba(38, 186, 171, 0.2)";
    //         let color4 = "rgba(38, 186, 171, 0.98)";
    //         let mytemp = reRender(arr3);
    //         let arr3_0 = mytemp.hasdata;
    //         let arr3_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           arr3_0,
    //           arr3_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         let a2 = Math.round(avg2 / days); //浅睡平均
    //         if (a2 > 60) {
    //           let b = Math.floor(a2 / 60);
    //           let c = a2 % 60;
    //           $("#deep-data2").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week2").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a2 % 60;
    //           $("#deep-data2").html(0 + " hr " + c + " min");
    //           $(".title-text-week2").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //       } else if (model == "heart") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let color = "rgba(219, 74, 106, 1)";
    //         let color2 = "rgba(219, 74, 106, 0.8)";
    //         let color3 = "rgba(219, 74, 106, 0.2)";
    //         let heart = res.data.heart_rate_stage;
    //         let avg = 0;
    //         let days = 0;
    //         for (let i = 0; i < heart.length; i++) {
    //           if (heart[i] != "-") {
    //             avg = heart[i] + avg;
    //             days = days + 1;
    //           }
    //         }
    //         if (avg != 0) {
    //           $(".title-text-week2").html(Math.round(avg / days) + " bpm");
    //         } else {
    //           $(".title-text-week2").html("0 bpm");
    //         }
    //         let color4 = "rgba(219, 74, 106, 0.9)";
    //         let mytemp = reRender(heart);
    //         let heart_0 = mytemp.hasdata;
    //         let heart_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           heart_0,
    //           heart_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "breath") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let color = "rgba(111, 148, 216, 1)";
    //         let color2 = "rgba(111, 148, 216, 0.8)";
    //         let color3 = "rgba(111, 148, 216, 0.2)";
    //         let breath = res.data.breath_rate_stage;
    //         let avg = 0;
    //         let days = 0;
    //         // let temparr = res.data.breath_rate_stage;
    //         for (let i = 0; i < breath.length; i++) {
    //           if (breath[i] != "-") {
    //             avg = breath[i] + avg;
    //             days = days + 1;
    //           }
    //         }
    //         if (avg != 0) {
    //           $(".title-text-week2").html(
    //             Math.round(avg / days) + " " + languageData.lab_14
    //           );
    //         } else {
    //           $(".title-text-week2").html("0 " + languageData.lab_14);
    //         }
    //         let color4 = "rgba(111, 148, 216, 0.9)";
    //         let mytemp = reRender(breath);
    //         let breath_0 = mytemp.hasdata;
    //         let breath_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           breath_0,
    //           breath_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "move") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let slm = res.data.twitch_times_stage;
    //         let avg = 0;
    //         let days = 0;
    //         let color = "rgba(242, 186, 91, 1)";
    //         let color2 = "rgba(242, 186, 91, 0.8)";
    //         let color3 = "rgba(242, 186, 91, 0.2)";
    //         for (let i = 0; i < slm.length; i++) {
    //           if (slm[i] != "-") {
    //             avg = slm[i] + avg;
    //             days = days + 1;
    //           }
    //         }
    //         if (avg != 0) {
    //           $(".title-text-week2").html(
    //             Math.round(avg / days) +
    //             (Math.round(avg / days) == 1
    //               ? " " + languageData.lab_10.slice(0, -1)
    //               : " " + languageData.lab_10)
    //           );
    //         } else {
    //           $(".title-text-week2").html("0 " + languageData.lab_10);
    //         }
    //         let color4 = "rgba(242, 186, 91, 0.9)";
    //         let mytemp = reRender(slm);
    //         let slm_0 = mytemp.hasdata;
    //         let slm_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           slm_0,
    //           slm_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "hrv") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         let color = "rgba(181, 41, 72, 1)";
    //         let color2 = "rgba(181, 41, 72, 1)";
    //         let color3 = "rgba(181, 41, 72, 0.2)";
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let rmssd = res.data.rmssd_stage;
    //         let avg3 = 0;
    //         let days = 0;
    //         for (let i = 0; i < rmssd.length; i++) {
    //           if (rmssd[i] != "-") {
    //             days = days + 1;
    //             avg3 = avg3 + rmssd[i];
    //           }
    //         }
    //         console.log("avg3===>", avg3, days);
    //         if (avg3 != 0) {
    //           $(".title-text-week2").html(Math.round(avg3 / days) + " ms");
    //         } else {
    //           $(".title-text-week2").html("0 ms");
    //         }
    //         let color4 = "rgba(181, 41, 72, 0.9)";
    //         let mytemp = reRender(rmssd);
    //         let rmssd_0 = mytemp.hasdata;
    //         let rmssd_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           rmssd_0,
    //           rmssd_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         // drawmonthchart(chart_sdnn, sdnn, arr, color2);
    //       } else if (model == "snore") {
    //         $(".subtext-week").html(languageData.lab_9);
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let color = "rgba(38,186,171,1)";
    //         let color2 = "rgba(38,186,171,0.8)";
    //         let color3 = "rgba(38,186,171,0.2)";
    //         let snore = res.data.snore_times_stage;
    //         let avg = 0;
    //         let avg2 = 0;
    //         let days = 0;
    //         let sum0 = res.data.snore_times_stage;
    //         let sum = res.data.anti_snore_times_stage;
    //         for (let i = 0; i < sum.length; i++) {
    //           if (sum[i] != "-") {
    //             days = days + 1;
    //             avg = avg + sum[i];
    //           }
    //         }
    //         for (let i = 0; i < sum0.length; i++) {
    //           if (sum0[i] != "-") {
    //             avg2 = avg2 + sum0[i];
    //           }
    //         }
    //         if (avg2 != 0) {
    //           $(".title-text-week2").html(
    //             Math.round(avg2 / sum0.length) +
    //             (Math.round(avg2 / sum0.length) == 1
    //               ? " " + languageData.lab_11
    //               : " " + languageData.lab_12)
    //           );
    //         } else {
    //           $(".title-text-week2").html("0 " + languageData.lab_12);
    //         }

    //         if (avg != 1) {
    //           $("#top-text2").html(
    //             Math.round(avg / days) + " " + languageData.snore_text
    //           );
    //         } else {
    //           $("#top-text2").html("1 " + languageData.snore_text1);
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //         let color4 = "rgba(38,186,171,0.9)";
    //         let mytemp = reRender(snore);
    //         let snore_0 = mytemp.hasdata;
    //         let snore_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           snore_0,
    //           snore_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "outbed") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_week = echarts.init(
    //           document.getElementById("chart_week")
    //         );
    //         let color = "rgba(240, 92, 73, 1)";
    //         let color2 = "rgba(240, 92, 73, 1)";
    //         let color3 = "rgba(240, 92, 73, 0.2)";
    //         let temp = res.data.left_bed_time;
    //         if (temp != 1) {
    //           $(".title-text-week2").html(temp + " times");
    //         } else {
    //           $(".title-text-week2").html(temp + " time");
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //         let color4 = "rgba(240, 92, 73, 0.9)";
    //         let mytemp = reRender(res.data.left_bed_times);
    //         let left_0 = mytemp.hasdata;
    //         let left_1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_week,
    //           left_0,
    //           left_1,
    //           arr,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else {
    //       }
    //     }
    //   },
    // });
  }
  //月报
  function getmonthreport() {
    // let arr = [];
    // let value0 = [];
    // let value1 = [];
    // let value2 = [];
    // let value3 = [];
    let time = dateformat(
      new Date(date.replace(/-/g, "/")).getTime() - 24 * 60 * 60 * 30 * 1000,
      0,
      2
    );
    let url = "";
    if (host == 1) {
      url =
        "https://wellness.ergomotion.com/agingInPlace/api/v1/sleep/getSleepMonth";
    } else {
      url =
        "https://resthomeus.smartbed.top/agingInPlace/api/v1/sleep/getSleepMonth";
    }
    let temp2 = new Date(time.replace(/-/g, "/") + " 00:00:00");
    let yn2 = temp2.getFullYear();
    let mn2 = temp2.getMonth();
    let dn2 = temp2.getDate();
    if (yn2 != yn) {
      $("#time-toptext").html(
        MonthArr[mn2] +
        " " +
        dn2 +
        ", " +
        yn2 +
        " - " +
        MonthArr[mn] +
        " " +
        dn +
        ", " +
        yn
      );
    } else {
      $("#time-toptext").html(
        MonthArr[mn2] +
        " " +
        dn2 +
        " - " +
        MonthArr[mn] +
        " " +
        dn +
        ", " +
        yn
      );
    }
    mockMonthData()
    // $.ajax({
    //   url: url,
    //   type: "get",
    //   data: {
    //     user_id: user_id,
    //     start_date: time,
    //     end_date: date.substring(0, 10),
    //   },
    //   headers: {
    //     Authorization: token,
    //   },
    //   datatype: "application/json",
    //   success: function (res) {
    //     let sum = res.data;
    //     let avg = 0;
    //     let avg1 = 0;
    //     let avg2 = 0;
    //     let avg3 = 0;
    //     let days = 0;
    //     if (res.code == 10000) {
    //       arr = res.data.date;
    //       for (let i = 0; i < arr.length; i++) {
    //         let a = arr[i].substring(5, 10).split("-");
    //         let temp_date_1 = parseInt(a[0]).toString();
    //         let temp_date_2 = parseInt(a[1]).toString();
    //         let b = temp_date_1 + "/" + temp_date_2;
    //         value0.push(b);
    //       }
    //       for (let i = 0; i < arr.length; i++) {
    //         value1.push(res.data.deep_sleep_durations[i]);
    //         value2.push(res.data.shallow_sleep_durations[i]);
    //         value3.push(res.data.clear_durations[i]);
    //         if (
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0) +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0) +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0) !=
    //           0
    //         ) {
    //           days = days + 1;
    //         }
    //         avg =
    //           avg +
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0) +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0) +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0);
    //         avg1 =
    //           avg1 +
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0);
    //         avg2 =
    //           avg2 +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0);
    //         avg3 =
    //           avg3 +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0);
    //       }
    //       let max;
    //       let max1 = Math.max(...value1);
    //       let max2 = Math.max(...value2);
    //       let max3 = Math.max(...value3);
    //       if (max1 > max2) {
    //         if (max1 > max3) {
    //           max = max1;
    //         } else {
    //           max = max3;
    //         }
    //       } else {
    //         if (max2 > max3) {
    //           max = max2;
    //         } else {
    //           max = max3;
    //         }
    //       }
    //       let lab_0 = value0[0];
    //       console.log("value0", value0);
    //       let lab_1 = value0[value0.length - 1];
    //       $("#monthlab").html(
    //         languageData.lab_4 + ", " + lab_0 + "-" + lab_1
    //       );
    //       $(".subtext-week").html(languageData.lab_7);
    //       $("#month_x_4").html(value0[value0.length - 1]);
    //       $("#month_x_3").html(value0[value0.length - 11]);
    //       $("#month_x_2").html(value0[value0.length - 21]);
    //       $("#month_x_1").html(value0[value0.length - 31]);
    //       //不同模块处理
    //       if (model == "total") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_month_total = echarts.init(
    //           document.getElementById("chart_month_total")
    //         );
    //         let s = Math.round(avg / days); //总平均
    //         let a1 = Math.round(avg1 / days); //深睡平均
    //         let a2 = Math.round(avg2 / days); //浅睡平均
    //         let a3 = Math.round(avg3 / days); //清醒平均
    //         let interval = Math.floor(value0.length / 4);
    //         console.log("value1", value1);
    //         let mytemp1 = reRender(value1);
    //         let mytemp2 = reRender(value2);
    //         let mytemp3 = reRender(value3);
    //         let value1_0 = mytemp1.hasdata;
    //         let value1_1 = mytemp1.nodata;
    //         let value2_0 = mytemp2.hasdata;
    //         let value2_1 = mytemp2.nodata;
    //         let value3_0 = mytemp3.hasdata;
    //         let value3_1 = mytemp3.nodata;
    //         console.log("value1====>", value1_0, value1_1);
    //         // drawweekchart(chart_month_total, value1_0, value1_1, value2_0, value2_1, value3, value0, interval, max);
    //         drawweekchart(
    //           chart_month_total,
    //           value1_0,
    //           value1_1,
    //           value2_0,
    //           value2_1,
    //           value3_0,
    //           value3_1,
    //           value0,
    //           interval,
    //           max
    //         );
    //         let sleep_duration = Math.round(
    //           (sum.deep_sleep_duration + sum.shallow_sleep_duration) / 30
    //         );
    //         if (sleep_duration > 60) {
    //           let b = Math.floor(sleep_duration / 60);
    //           let c = sleep_duration % 60;
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = sleep_duration % 60;
    //           $(".title-text-week3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a1 > 60) {
    //           let b = Math.floor(a1 / 60);
    //           let c = a1 % 60;
    //           $(".deep-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a1.deep_sleep_duration % 60;
    //           $(".deep-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a2 > 60) {
    //           let b = Math.floor(a2 / 60);
    //           let c = a2 % 60;
    //           $(".light-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a2 % 60;
    //           $(".light-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a3 > 60) {
    //           let b = Math.floor(a3 / 60);
    //           let c = a3 % 60;
    //           $(".awake-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a3 % 60;
    //           $(".awake-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //       } else if (model == "deep") {
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let color = "rgba(38, 84, 166, 1)";
    //         let color2 = "rgba(38, 84, 166, 1)";
    //         let color3 = "rgba(38, 84, 166, 0.2)";
    //         let color4 = "rgba(38, 84, 166, 0.82)";
    //         let mytemp1 = reRender(value1);
    //         let value1_0 = mytemp1.hasdata;
    //         let value1_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_month,
    //           value1_0,
    //           value1_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         let sleep_duration = Math.round(sum.avg_deep_sleep_duration);
    //         if (sleep_duration > 60) {
    //           let b = Math.floor(sleep_duration / 60);
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(0 + " hr " + c + " min");
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //       } else if (model == "light") {
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let color = "rgba(38, 186, 171, 1)";
    //         let color2 = "rgba(38, 186, 171, 1)";
    //         let color3 = "rgba(38, 186, 171, 0.2)";
    //         let color4 = "rgba(38, 186, 171, 0.79)";
    //         let mytemp2 = reRender(value2);
    //         let value2_0 = mytemp2.hasdata;
    //         let value2_1 = mytemp2.nodata;
    //         drawmonthchart(
    //           chart_month,
    //           value2_0,
    //           value2_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         let sleep_duration = Math.round(sum.avg_shallow_sleep_duration);
    //         if (sleep_duration > 60) {
    //           let b = Math.floor(sleep_duration / 60);
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //       } else if (model == "heart") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let color = "rgba(219, 74, 106, 1)";
    //         let color2 = "rgba(219, 74, 106, 1)";
    //         let color3 = "rgba(219, 74, 106, 0.2)";
    //         let color4 = "rgba(219, 74, 106, 0.89)";
    //         let sum = 0;
    //         let days = 0;
    //         let heart = res.data.heart_rate_stage;
    //         for (let i = 0; i < heart.length; i++) {
    //           if (heart[i] != "-") {
    //             sum = sum + heart[i];
    //             days = days + 1;
    //           }
    //         }
    //         if (sum != 0) {
    //           $(".title-text-week3").html(Math.round(sum / days) + " bpm");
    //         } else {
    //           $(".title-text-week3").html("0 bpm");
    //         }
    //         let mytemp = reRender(heart);
    //         let heart0 = mytemp.hasdata;
    //         let heart1 = mytemp.nodata;
    //         console.log("heart===>", mytemp);
    //         drawmonthchart(
    //           chart_month,
    //           heart0,
    //           heart1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "breath") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let color = "rgba(111, 148, 216, 1)";
    //         let color2 = "rgba(111, 148, 216, 1)";
    //         let color3 = "rgba(111, 148, 216, 0.2)";
    //         let color4 = "rgba(111, 148, 216, 1)";
    //         let breath = [];
    //         let sum = 0;
    //         let days = 0;
    //         let arr_1 = res.data.avg_breath_rate;
    //         breath = res.data.breath_rate_stage;
    //         $(".title-text-week3").html(arr_1 + " " + languageData.lab_14);
    //         let mytemp = reRender(breath);
    //         let breath0 = mytemp.hasdata;
    //         let breath1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_month,
    //           breath0,
    //           breath1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "move") {
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let color = "rgba(242, 186, 91, 1)";
    //         let color2 = "rgba(242, 186, 91, 0.8)";
    //         let color3 = "rgba(242, 186, 91, 0.2)";
    //         let color4 = "rgba(242, 186, 91, 0.89)";
    //         let move = res.data.twitch_times_stage;
    //         let sum = 0;
    //         let days = 0;
    //         for (let i = 0; i < move.length; i++) {
    //           if (move[i] != "-") {
    //             sum = sum + move[i];
    //             days = days + 1;
    //           }
    //         }
    //         if (sum != 1) {
    //           $(".title-text-week3").html(
    //             Math.round(sum / days) +
    //             (Math.round(sum / days) == 1
    //               ? " " + languageData.lab_10.slice(0, -1)
    //               : " " + languageData.lab_10)
    //           );
    //         } else {
    //           $(".title-text-week3").html("0 " + languageData.lab_10);
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //         let mytemp = reRender(move);
    //         let move0 = mytemp.hasdata;
    //         let move1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_month,
    //           move0,
    //           move1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "hrv") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let data = res.data.rmssd_stage;
    //         let color = "rgba(181, 41, 72, 1)";
    //         let color2 = "rgba(181, 41, 72, 1)";
    //         let color3 = "rgba(181, 41, 72, 0.2)";
    //         let color4 = "rgba(181, 41, 72, 0.84)";
    //         let avg3 = 0;
    //         let rmssd = res.data.rmssd_stage;
    //         let days = 0;
    //         for (let i = 0; i < rmssd.length; i++) {
    //           if (rmssd[i] != "-") {
    //             days = days + 1;
    //             avg3 = avg3 + rmssd[i];
    //           }
    //         }
    //         $(".hrv_month_num3 ").html(Math.round(avg3 / days));
    //         if (avg3 != 0) {
    //           $(".title-text-week3").html(Math.round(avg3 / days) + " ms");
    //         } else {
    //           $(".title-text-week3").html("0 ms");
    //         }
    //         let mytemp = reRender(rmssd);
    //         let rmssd0 = mytemp.hasdata;
    //         let rmssd1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_month,
    //           rmssd0,
    //           rmssd1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         $(".hrv_week_daterow").html(
    //           languageData.lab_4 + ", " + lab_0[0] + "-" + lab_1[1]
    //         );
    //       } else if (model == "snore") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let color = "rgba(38, 186, 171, 1)";
    //         let color2 = "rgba(38, 186, 171, 1)";
    //         let color3 = "rgba(38, 186, 171,0.2)";
    //         let color4 = "rgba(38, 186, 171,0.6)";
    //         let snore = res.data.snore_times_stage;
    //         let avg = 0;
    //         let avg2 = 0;
    //         let days = 0;
    //         let sum0 = res.data.snore_times_stage;
    //         let sum = res.data.anti_snore_times_stage;
    //         for (let i = 0; i < sum.length; i++) {
    //           if (sum[i] != "-") {
    //             days = days + 1;
    //             avg = avg + sum[i];
    //           }
    //         }
    //         for (let i = 0; i < sum0.length; i++) {
    //           if (sum0[i] != "-") {
    //             avg2 = avg2 + sum0[i];
    //           }
    //         }
    //         if (avg2 != 0) {
    //           $(".title-text-week3").html(
    //             Math.round(avg2 / sum0.length) +
    //             (Math.round(avg2 / sum0.length) == 1
    //               ? " " + languageData.lab_11
    //               : " " + languageData.lab_12)
    //           );
    //         } else {
    //           $(".title-text-week3").html("0 " + languageData.lab_12);
    //         }
    //         if (avg != 0) {
    //           $("#top-text3").html(
    //             Math.round(avg / days) +
    //             (Math.round(avg / days) == 1
    //               ? " " + languageData.snore_text1
    //               : " " + languageData.snore_text)
    //           );
    //         } else {
    //           $("#top-text3").html("0 " + languageData.snore_text);
    //         }
    //         let mytemp = reRender(snore);
    //         let snore0 = mytemp.hasdata;
    //         let snore1 = mytemp.nodata;
    //         console.log("mytemp===>", mytemp);
    //         drawmonthchart(
    //           chart_month,
    //           snore0,
    //           snore1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "outbed") {
    //         var chart_month = echarts.init(
    //           document.getElementById("chart_month")
    //         );
    //         let color = "rgba(240, 92, 73, 1)";
    //         let color2 = "rgba(240, 92, 73, 1)";
    //         let color3 = "rgba(240, 92, 73, 0.2)";
    //         let color4 = "rgba(240, 92, 73, 0.55)";
    //         let temp = res.data.left_bed_times;
    //         let temp2 = res.data.left_bed_time;
    //         if (temp2 != 1) {
    //           $(".title-text-week3").html(temp2 + " " + languageData.lab_12);
    //         } else {
    //           $(".title-text-week3").html(temp2 + " " + languageData.lab_11);
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //         let mytemp = reRender(temp);
    //         let temp0 = mytemp.hasdata;
    //         let temp1 = mytemp.nodata;
    //         drawmonthchart(
    //           chart_month,
    //           temp0,
    //           temp1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       }
    //     }
    //   },
    // });
  }
  //年报
  function getyearreport() {
    // let arr = [];
    // let value0 = [];
    // let value1 = [];
    // let value2 = [];
    // let value3 = [];
    // let time = dateformat(
    //   new Date(date.replace(/-/g, "/")).getTime() - 24 * 60 * 60 * 365 * 1000,
    //   0,
    //   2
    // );
    let url = "";
    if (host == 1) {
      url =
        "https://wellness.ergomotion.com/agingInPlace/api/v1/sleep/getSleepYearN";
    } else {
      url =
        "https://resthomeus.smartbed.top/agingInPlace/api/v1/sleep/getSleepYearN";
    }
    // let temp2 = new Date(time.replace(/-/g, "/") + " 00:00:00");
    // let yn2 = temp2.getFullYear();
    // let mn2 = temp2.getMonth();
    // let dn2 = temp2.getDate();
    mockYearData()
    // $.ajax({
    //   url: url,
    //   type: "get",
    //   data: {
    //     user_id: user_id,
    //     start_date: time,
    //     end_date: date.substring(0, 10),
    //   },
    //   headers: {
    //     Authorization: token,
    //   },
    //   datatype: "application/json",
    //   success: function (res) {
    //     let sum = res.data;
    //     let avg = 0;
    //     let avg1 = 0;
    //     let avg2 = 0;
    //     let avg3 = 0;
    //     let days = 0;
    //     if (res.code == 10000) {
    //       let tempdate = new Date(
    //         res.data.date[0].replace(/-/g, "/") + " 00:00:00"
    //       );
    //       let mn3 = tempdate.getMonth();
    //       let dn3 = tempdate.getDate();
    //       if (mn2 == mn3 && dn2 == dn3) {
    //         if (yn2 != yn) {
    //           $("#time-toptext").html(
    //             MonthArr[mn2] +
    //             " " +
    //             dn2 +
    //             ", " +
    //             yn2 +
    //             " - " +
    //             MonthArr[mn] +
    //             " " +
    //             dn +
    //             ", " +
    //             yn
    //           );
    //         } else {
    //           $("#time-toptext").html(
    //             MonthArr[mn2] +
    //             " " +
    //             dn2 +
    //             " - " +
    //             MonthArr[mn] +
    //             " " +
    //             dn +
    //             ", " +
    //             yn
    //           );
    //         }
    //       } else {
    //         if (yn2 != yn) {
    //           $("#time-toptext").html(
    //             MonthArr[mn3] +
    //             " " +
    //             dn3 +
    //             ", " +
    //             yn2 +
    //             " - " +
    //             MonthArr[mn] +
    //             " " +
    //             dn +
    //             ", " +
    //             yn
    //           );
    //         } else {
    //           $("#time-toptext").html(
    //             MonthArr[mn3] +
    //             " " +
    //             dn3 +
    //             " - " +
    //             MonthArr[mn] +
    //             " " +
    //             dn +
    //             ", " +
    //             yn
    //           );
    //         }
    //       }
    //       //arr = res.data.sleep_duration_year;
    //       for (let i = 0; i < res.data.date.length; i++) {
    //         let a = res.data.date[i].substring(5, 10).split("-");
    //         let temp_date_1 = parseInt(a[0]).toString();
    //         let temp_date_2 = parseInt(a[1]).toString();
    //         let b = temp_date_1 + "/" + temp_date_2;
    //         value0.push(b);
    //       }
    //       for (let i = 0; i < res.data.date.length; i++) {
    //         value1.push(res.data.deep_sleep_durations[i]);
    //         value2.push(res.data.shallow_sleep_durations[i]);
    //         value3.push(res.data.clear_durations[i]);
    //         if (
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0) +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0) +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0) !=
    //           0
    //         ) {
    //           days = days + 1;
    //         }
    //         avg =
    //           avg +
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0) +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0) +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0);
    //         avg1 =
    //           avg1 +
    //           (res.data.deep_sleep_durations[i] != "-"
    //             ? res.data.deep_sleep_durations[i]
    //             : 0);
    //         avg2 =
    //           avg2 +
    //           (res.data.shallow_sleep_durations[i] != "-"
    //             ? res.data.shallow_sleep_durations[i]
    //             : 0);
    //         avg3 =
    //           avg3 +
    //           (res.data.clear_durations[i] != "-"
    //             ? res.data.clear_durations[i]
    //             : 0);
    //       }
    //       let max;
    //       let max1 = Math.max(...value1);
    //       let max2 = Math.max(...value2);
    //       let max3 = Math.max(...value3);
    //       if (max1 > max2) {
    //         if (max1 > max3) {
    //           max = max1;
    //         } else {
    //           max = max3;
    //         }
    //       } else {
    //         if (max2 > max3) {
    //           max = max2;
    //         } else {
    //           max = max3;
    //         }
    //       }
    //       let lab_0 = value0[0];
    //       let lab_1 = value0[value0.length - 1];
    //       if (yn2 != yn) {
    //         $("#yearlab").html(
    //           languageData.lab_5 +
    //           ", " +
    //           lab_0 +
    //           "/" +
    //           yn2.toString().substring(2, 4) +
    //           "-" +
    //           lab_1 +
    //           "/" +
    //           yn.toString().substring(2, 4)
    //         );
    //       } else {
    //         $("#yearlab").html(
    //           languageData.lab_5 + ", " + lab_0 + "-" + lab_1
    //         );
    //       }
    //       $(".subtext-week").html(languageData.lab_5);
    //       let x_arr = [];
    //       if (value0.length != 0) {
    //         let temparr = [];
    //         value0.forEach((item) => {
    //           temparr.push(parseInt(item.split("/")[0]));
    //         });
    //         if (temparr[0] == temparr[temparr.length - 1]) {
    //           if (temparr.length == 1) {
    //             x_arr = [...new Set(temparr)];
    //           } else {
    //             let temp = temparr[temparr.length - 1];
    //             x_arr = [...new Set(temparr)];
    //             x_arr.push(temp);
    //           }
    //         } else {
    //           x_arr = [...new Set(temparr)];
    //         }
    //         console.log("xarr", x_arr);
    //         if (x_arr.length == 1) {
    //           $("#chart_year_x").css({ display: "block" });
    //           $("#chart_year_x2").css({ display: "none" });
    //           $("#chart_year_x3").css({ display: "none" });
    //           $("#chart_year_x4").css({ display: "none" });
    //           $("#year_x_1").html(MonthArr[x_arr[0] - 1]);
    //         }
    //         if (x_arr.length == 2) {
    //           $("#chart_year_x").css({ display: "none" });
    //           $("#chart_year_x2").css({ display: "block" });
    //           $("#chart_year_x3").css({ display: "none" });
    //           $("#chart_year_x4").css({ display: "none" });
    //           $("#year_x2_1").html(MonthArr[x_arr[0] - 1]);
    //           $("#year_x2_2").html(MonthArr[x_arr[1] - 1]);
    //         }
    //         if (x_arr.length == 3) {
    //           $("#chart_year_x").css({ display: "none" });
    //           $("#chart_year_x2").css({ display: "none" });
    //           $("#chart_year_x3").css({ display: "block" });
    //           $("#chart_year_x4").css({ display: "none" });
    //           $("#year_x3_1").html(MonthArr[x_arr[0] - 1]);
    //           $("#year_x3_2").html(MonthArr[x_arr[1] - 1]);
    //           $("#year_x3_3").html(MonthArr[x_arr[2] - 1]);
    //         }
    //         if (x_arr.length >= 4) {
    //           $("#chart_year_x").css({ display: "none" });
    //           $("#chart_year_x2").css({ display: "none" });
    //           $("#chart_year_x3").css({ display: "none" });
    //           $("#chart_year_x4").css({ display: "block" });
    //           $("#year_x4_1").html(MonthArr[x_arr[0] - 1]);
    //           $("#year_x4_2").html(MonthArr[x_arr[1] - 1]);
    //           $("#year_x4_3").html(MonthArr[x_arr[2] - 1]);
    //           $("#year_x4_4").html(MonthArr[x_arr[3] - 1]);
    //           if (x_arr.length == 5 || x_arr.length == 6) {
    //             $("#year_x4_1").html(MonthArr[x_arr[0] - 1]);
    //             $("#year_x4_2").html(MonthArr[x_arr[2] - 1]);
    //             $("#year_x4_3").html(MonthArr[x_arr[4] - 1]);
    //             $("#year_x4_4").html(MonthArr[x_arr[x_arr.length - 1] - 1]);
    //           }
    //           if (x_arr.length == 7 || x_arr.length == 8) {
    //             $("#year_x4_1").html(MonthArr[x_arr[0] - 1]);
    //             $("#year_x4_2").html(MonthArr[x_arr[2] - 1]);
    //             $("#year_x4_3").html(MonthArr[x_arr[4] - 1]);
    //             $("#year_x4_4").html(MonthArr[x_arr[6] - 1]);
    //           }
    //           if (x_arr.length == 10) {
    //             $("#year_x4_1").html(MonthArr[x_arr[0] - 1]);
    //             $("#year_x4_2").html(MonthArr[x_arr[3] - 1]);
    //             $("#year_x4_3").html(MonthArr[x_arr[6] - 1]);
    //             $("#year_x4_4").html(MonthArr[x_arr[9] - 1]);
    //           }
    //           if (x_arr.length == 11) {
    //             $("#year_x4_1").html(MonthArr[x_arr[0] - 1]);
    //             $("#year_x4_2").html(MonthArr[x_arr[4] - 1]);
    //             $("#year_x4_3").html(MonthArr[x_arr[8] - 1]);
    //             $("#year_x4_4").html(MonthArr[x_arr[10] - 1]);
    //           }
    //           if (x_arr.length == 12) {
    //             $("#year_x4_1").html(MonthArr[x_arr[0] - 1]);
    //             $("#year_x4_2").html(MonthArr[x_arr[4] - 1]);
    //             $("#year_x4_3").html(MonthArr[x_arr[8] - 1]);
    //             $("#year_x4_4").html(MonthArr[x_arr[11] - 1]);
    //           }
    //           if (x_arr.length == 13) {
    //             $("#year_x4_1").html(MonthArr[x_arr[0] - 1]);
    //             $("#year_x4_2").html(MonthArr[x_arr[4] - 1]);
    //             $("#year_x4_3").html(MonthArr[x_arr[8] - 1]);
    //             $("#year_x4_4").html(MonthArr[x_arr[12] - 1]);
    //           }
    //         }
    //         // if (x_arr.length == 5 || x_arr.length == 6 || x_arr.length == 9) {
    //         //   $('#chart_year_x').css({ display: 'none' })
    //         //   $('#chart_year_x2').css({ display: 'none' })
    //         //   $('#chart_year_x3').css({ display: 'block' })
    //         //   $('#chart_year_x4').css({ display: 'none' })
    //         //   $('#year_x3_1').html(MonthArr[x_arr[0] - 1])
    //         //   $('#year_x3_2').html(MonthArr[x_arr[2] - 1])
    //         //   $('#year_x3_3').html(MonthArr[x_arr[4] - 1])
    //         //   if (x_arr.length == 9) {
    //         //     $('#year_x3_1').html(MonthArr[x_arr[0] - 1])
    //         //     $('#year_x3_2').html(MonthArr[x_arr[4] - 1])
    //         //     $('#year_x3_3').html(MonthArr[x_arr[8] - 1])
    //         //   }
    //         // }
    //       }

    //       //不同模块处理
    //       if (model == "total") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_year_total = echarts.init(
    //           document.getElementById("chart_year_total")
    //         );
    //         let s = Math.round(avg / days); //总平均
    //         let a1 = Math.round(avg1 / days); //深睡平均
    //         let a2 = Math.round(avg2 / days); //浅睡平均
    //         let a3 = Math.round(avg3 / days); //清醒平均
    //         let mytemp1 = reRender(value1);
    //         let mytemp2 = reRender(value2);
    //         let mytemp3 = reRender(value3);
    //         let value1_0 = mytemp1.hasdata;
    //         let value1_1 = mytemp1.nodata;
    //         let value2_0 = mytemp2.hasdata;
    //         let value2_1 = mytemp2.nodata;
    //         let value3_0 = mytemp3.hasdata;
    //         let value3_1 = mytemp3.nodata;
    //         drawweekchart(
    //           chart_year_total,
    //           value1_0,
    //           value1_1,
    //           value2_0,
    //           value2_1,
    //           value3_0,
    //           value3_1,
    //           value0,
    //           max
    //         );
    //         let sleep_duration = Math.round(
    //           sum.avg_deep_sleep_duration + sum.avg_shallow_sleep_duration
    //         );
    //         if (sleep_duration > 60) {
    //           let b = Math.floor(sleep_duration / 60);
    //           let c = sleep_duration % 60;
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = sleep_duration % 60;
    //           $(".title-text-week3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a1 > 60) {
    //           let b = Math.floor(a1 / 60);
    //           let c = a1 % 60;
    //           $(".deep-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a1.deep_sleep_duration % 60;
    //           $(".deep-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a2 > 60) {
    //           let b = Math.floor(a2 / 60);
    //           let c = a2 % 60;
    //           $(".light-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a2 % 60;
    //           $(".light-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //         if (a3 > 60) {
    //           let b = Math.floor(a3 / 60);
    //           let c = a3 % 60;
    //           $(".awake-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = a3 % 60;
    //           $(".awake-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //       } else if (model == "deep") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(111, 148, 216, 1)";
    //         let color2 = "rgba(111, 148, 216, 1)";
    //         let color3 = "rgba(111, 148, 216, 0.2)";
    //         let color4 = "rgba(111, 148, 216, 0.89)";
    //         let mytemp1 = reRender(value1);
    //         let value1_0 = mytemp1.hasdata;
    //         let value1_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_year,
    //           value1_0,
    //           value1_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         let sleep_duration = Math.round(sum.avg_deep_sleep_duration);
    //         if (sleep_duration > 60) {
    //           let b = Math.floor(sleep_duration / 60);
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //       } else if (model == "light") {
    //         $(".subtext-week").html(languageData.lab_7);
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(38, 186, 171, 1)";
    //         let color2 = "rgba(38, 186, 171, 1)";
    //         let color3 = "rgba(38, 186, 171, 0.2)";
    //         let color4 = "rgba(38, 186, 171, 0.9)";
    //         let mytemp1 = reRender(value1);
    //         let value2_0 = mytemp1.hasdata;
    //         let value2_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_year,
    //           value2_0,
    //           value2_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         let sleep_duration = Math.round(sum.avg_shallow_sleep_duration);
    //         if (sleep_duration > 60) {
    //           let b = Math.floor(sleep_duration / 60);
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         } else {
    //           let c = sleep_duration % 60;
    //           $("#deep-data3").html(
    //             0 + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //           $(".title-text-week3").html(
    //             b + " " + languageData.lab_13 + " " + c + " min"
    //           );
    //         }
    //       } else if (model == "heart") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(219, 74, 106, 1)";
    //         let color2 = "rgba(219, 74, 106, 1)";
    //         let color3 = "rgba(219, 74, 106, 0.2)";
    //         let date = [];
    //         let sum = 0;
    //         let days = 0;
    //         // let arr_1 = res.data.date;
    //         // for (let i = 0; i < arr_1.length; i++) {
    //         //   date.push(arr_1[i].substring(5, 10).replace(/-/g, '/'));
    //         // }
    //         if (res.data.avg_heart_rate != 0) {
    //           $(".title-text-week3").html(res.data.avg_heart_rate + " bpm");
    //         } else {
    //           $(".title-text-week3").html("0 bpm");
    //         }
    //         let color4 = "rgba(219, 74, 106, 0.9)";
    //         let mytemp1 = reRender(res.data.heart_rate_stage);
    //         let heart_0 = mytemp1.hasdata;
    //         let heart_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_year,
    //           heart_0,
    //           heart_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "breath") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(111, 148, 216, 1)";
    //         let color2 = "rgba(111, 148, 216, 1)";
    //         let color3 = "rgba(111, 148, 216, 0.2)";
    //         let breath = [];
    //         let sum = 0;
    //         let days = 0;
    //         let arr_1 = res.data.avg_breath_rate;
    //         breath = res.data.breath_rate_stage;
    //         $(".title-text-week3").html(arr_1 + " " + languageData.lab_14);
    //         let color4 = "rgba(111, 148, 216, 0.9)";
    //         let mytemp1 = reRender(breath);
    //         let breath_0 = mytemp1.hasdata;
    //         let breath_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_year,
    //           breath_0,
    //           breath_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "move") {
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(242, 186, 91, 1)";
    //         let color2 = "rgba(242, 186, 91, 0.8)";
    //         let color3 = "rgba(242, 186, 91, 0.2)";
    //         let move = res.data.twitch_times_stage_year;
    //         let sum = 0;
    //         let days = 0;
    //         for (let i = 0; i < move.length; i++) {
    //           if (move[i] != "-") {
    //             sum = sum + move[i];
    //             days = days + 1;
    //           }
    //         }
    //         if (sum != 1) {
    //           $(".title-text-week3").html(
    //             Math.round(sum / days) + " " + languageData.lab_10
    //           );
    //         } else {
    //           $(".title-text-week3").html(
    //             "1 " + languageData.lab_10.slice(0, -1)
    //           );
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //         let color4 = "rgba(242, 186, 91, 0.9)";
    //         let mytemp1 = reRender(move);
    //         let move_0 = mytemp1.hasdata;
    //         let move_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_year,
    //           move_0,
    //           move_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "hrv") {
    //         $(".subtext-week").html(languageData.lab_8);
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(181, 41, 72, 1)";
    //         let color2 = "rgba(181, 41, 72, 1)";
    //         let color3 = "rgba(181, 41, 72, 0.2)";
    //         let avg3 = 0;
    //         let rmssd = res.data.rmssd_stage;
    //         let days = 0;
    //         for (let i = 0; i < rmssd.length; i++) {
    //           if (rmssd[i] != "-") {
    //             days = days + 1;
    //             avg3 = avg3 + rmssd[i];
    //           }
    //         }

    //         // $('.hrv_month_num3 ').html(Math.round(avg3 / days));
    //         if (avg3 != 0) {
    //           $(".title-text-week3").html(Math.round(avg3 / days) + " ms");
    //         } else {
    //           $(".title-text-week3").html("0 ms");
    //         }
    //         let color4 = "rgba(181, 41, 72, 0.2)";
    //         let mytemp1 = reRender(rmssd);
    //         let rmssd_0 = mytemp1.hasdata;
    //         let rmssd_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_year,
    //           rmssd_0,
    //           rmssd_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //         $(".hrv_week_daterow").html(
    //           languageData.lab_4 + "," + lab_0[0] + "-" + lab_1[1]
    //         );
    //       } else if (model == "snore") {
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(38, 186, 171, 1)";
    //         let color2 = "rgba(38, 186, 171, 0.8)";
    //         let color3 = "rgba(38, 186, 171, 0.2)";
    //         let snore = res.data.snore_times_stage;
    //         let avg = 0;
    //         let avg2 = 0;
    //         let days = 0;
    //         let sum0 = res.data.snore_times_stage;
    //         let sum = res.data.anti_snore_times_stage;
    //         for (let i = 0; i < sum.length; i++) {
    //           if (sum[i] != "-") {
    //             days = days + 1;
    //             avg = avg + sum[i];
    //           }
    //         }
    //         for (let i = 0; i < sum0.length; i++) {
    //           if (sum0[i] != "-") {
    //             avg2 = avg2 + sum0[i];
    //           }
    //         }
    //         if (avg2 != 1) {
    //           $(".title-text-week3").html(
    //             Math.round(avg2 / sum0.length) + " " + languageData.lab_12
    //           );
    //         } else {
    //           $(".title-text-week3").html("1 " + languageData.lab_11);
    //         }
    //         if (avg != 1) {
    //           $("#top-text4").html(
    //             Math.round(avg / days) + " " + languageData.snore_text
    //           );
    //         } else {
    //           $("#top-text4").html("1 " + languageData.snore_text1);
    //         }
    //         $(".subtext-week").html(languageData.lab_7);
    //         let color4 = "rgba(38, 186, 171, 0.88)";
    //         let mytemp1 = reRender(snore);
    //         let snore_0 = mytemp1.hasdata;
    //         let snore_1 = mytemp1.nodata;
    //         console.log("snore==>", snore);
    //         drawmonthchart(
    //           chart_year,
    //           snore_0,
    //           snore_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       } else if (model == "outbed") {
    //         var chart_year = echarts.init(
    //           document.getElementById("chart_year")
    //         );
    //         let color = "rgba(240, 92, 73, 1)";
    //         let color2 = "rgba(240, 92, 73, 1)";
    //         let color3 = "rgba(240, 92, 73, 0.2)";
    //         let temp = res.data.left_bed_times;
    //         let temp2 = res.data.left_bed_time;
    //         if (temp2 != 1) {
    //           $(".title-text-week3").html(temp2 + " times");
    //         } else {
    //           $(".title-text-week3").html(temp2 + " time");
    //         }
    //         $(".subtext-week").html("Nightly average");
    //         let color4 = "rgba(240, 92, 73, 0.9)";
    //         let mytemp1 = reRender(temp);
    //         let temp_0 = mytemp1.hasdata;
    //         let temp_1 = mytemp1.nodata;
    //         drawmonthchart(
    //           chart_year,
    //           temp_0,
    //           temp_1,
    //           value0,
    //           color2,
    //           color3,
    //           color3,
    //           color4
    //         );
    //       }
    //     }
    //   },
    // });
  }
</script>

</html>